diff --git a/vcsserver/config/settings_maker.py b/vcsserver/config/settings_maker.py --- a/vcsserver/config/settings_maker.py +++ b/vcsserver/config/settings_maker.py @@ -58,7 +58,7 @@ def aslist(obj, sep=None, strip=True): :param sep: :param strip: """ - if isinstance(obj, (basestring,)): + if isinstance(obj, str): if obj in ['', ""]: return [] diff --git a/vcsserver/git_lfs/tests/test_lfs_app.py b/vcsserver/git_lfs/tests/test_lfs_app.py --- a/vcsserver/git_lfs/tests/test_lfs_app.py +++ b/vcsserver/git_lfs/tests/test_lfs_app.py @@ -54,19 +54,19 @@ class TestLFSApplication(object): def test_app_deprecated_endpoint(self, git_lfs_app): response = git_lfs_app.post('/repo/info/lfs/objects', status=501) assert response.status_code == 501 - assert json.loads(response.text) == {u'message': u'LFS: v1 api not supported'} + assert json.loads(response.text) == {'message': 'LFS: v1 api not supported'} def test_app_lock_verify_api_not_available(self, git_lfs_app): response = git_lfs_app.post('/repo/info/lfs/locks/verify', status=501) assert response.status_code == 501 assert json.loads(response.text) == { - u'message': u'GIT LFS locking api not supported'} + 'message': 'GIT LFS locking api not supported'} def test_app_lock_api_not_available(self, git_lfs_app): response = git_lfs_app.post('/repo/info/lfs/locks', status=501) assert response.status_code == 501 assert json.loads(response.text) == { - u'message': u'GIT LFS locking api not supported'} + 'message': 'GIT LFS locking api not supported'} def test_app_batch_api_missing_auth(self, git_lfs_app): git_lfs_app.post_json( @@ -77,14 +77,14 @@ class TestLFSApplication(object): '/repo/info/lfs/objects/batch', params={}, status=400, extra_environ=http_auth) assert json.loads(response.text) == { - u'message': u'unsupported operation mode: `None`'} + 'message': 'unsupported operation mode: `None`'} def test_app_batch_api_missing_objects(self, git_lfs_app, http_auth): response = git_lfs_app.post_json( '/repo/info/lfs/objects/batch', params={'operation': 'download'}, status=400, extra_environ=http_auth) assert json.loads(response.text) == { - u'message': u'missing objects data'} + 'message': 'missing objects data'} def test_app_batch_api_unsupported_data_in_objects( self, git_lfs_app, http_auth): @@ -94,7 +94,7 @@ class TestLFSApplication(object): '/repo/info/lfs/objects/batch', params=params, status=400, extra_environ=http_auth) assert json.loads(response.text) == { - u'message': u'unsupported data in objects'} + 'message': 'unsupported data in objects'} def test_app_batch_api_download_missing_object( self, git_lfs_app, http_auth): @@ -105,12 +105,12 @@ class TestLFSApplication(object): extra_environ=http_auth) expected_objects = [ - {u'authenticated': True, - u'errors': {u'error': { - u'code': 404, - u'message': u'object: 123 does not exist in store'}}, - u'oid': u'123', - u'size': u'1024'} + {'authenticated': True, + 'errors': {'error': { + 'code': 404, + 'message': 'object: 123 does not exist in store'}}, + 'oid': '123', + 'size': '1024'} ] assert json.loads(response.text) == { 'objects': expected_objects, 'transfer': 'basic'} @@ -130,14 +130,14 @@ class TestLFSApplication(object): extra_environ=http_auth) expected_objects = [ - {u'authenticated': True, - u'actions': { - u'download': { - u'header': {u'Authorization': u'Basic XXXXX'}, - u'href': u'http://localhost/repo/info/lfs/objects/456'}, + {'authenticated': True, + 'actions': { + 'download': { + 'header': {'Authorization': 'Basic XXXXX'}, + 'href': 'http://localhost/repo/info/lfs/objects/456'}, }, - u'oid': u'456', - u'size': u'1024'} + 'oid': '456', + 'size': '1024'} ] assert json.loads(response.text) == { 'objects': expected_objects, 'transfer': 'basic'} @@ -149,18 +149,18 @@ class TestLFSApplication(object): '/repo/info/lfs/objects/batch', params=params, extra_environ=http_auth) expected_objects = [ - {u'authenticated': True, - u'actions': { - u'upload': { - u'header': {u'Authorization': u'Basic XXXXX', - u'Transfer-Encoding': u'chunked'}, - u'href': u'http://localhost/repo/info/lfs/objects/123'}, - u'verify': { - u'header': {u'Authorization': u'Basic XXXXX'}, - u'href': u'http://localhost/repo/info/lfs/verify'} + {'authenticated': True, + 'actions': { + 'upload': { + 'header': {'Authorization': 'Basic XXXXX', + 'Transfer-Encoding': 'chunked'}, + 'href': 'http://localhost/repo/info/lfs/objects/123'}, + 'verify': { + 'header': {'Authorization': 'Basic XXXXX'}, + 'href': 'http://localhost/repo/info/lfs/verify'} }, - u'oid': u'123', - u'size': u'1024'} + 'oid': '123', + 'size': '1024'} ] assert json.loads(response.text) == { 'objects': expected_objects, 'transfer': 'basic'} @@ -172,18 +172,18 @@ class TestLFSApplication(object): '/repo/info/lfs/objects/batch', params=params, extra_environ=http_auth) expected_objects = [ - {u'authenticated': True, - u'actions': { - u'upload': { - u'header': {u'Authorization': u'Basic XXXXX', - u'Transfer-Encoding': u'chunked'}, - u'href': u'https://localhost/repo/info/lfs/objects/123'}, - u'verify': { - u'header': {u'Authorization': u'Basic XXXXX'}, - u'href': u'https://localhost/repo/info/lfs/verify'} + {'authenticated': True, + 'actions': { + 'upload': { + 'header': {'Authorization': 'Basic XXXXX', + 'Transfer-Encoding': 'chunked'}, + 'href': 'https://localhost/repo/info/lfs/objects/123'}, + 'verify': { + 'header': {'Authorization': 'Basic XXXXX'}, + 'href': 'https://localhost/repo/info/lfs/verify'} }, - u'oid': u'123', - u'size': u'1024'} + 'oid': '123', + 'size': '1024'} ] assert json.loads(response.text) == { 'objects': expected_objects, 'transfer': 'basic'} @@ -195,7 +195,7 @@ class TestLFSApplication(object): status=400) assert json.loads(response.text) == { - u'message': u'missing oid and size in request data'} + 'message': 'missing oid and size in request data'} def test_app_verify_api_missing_obj(self, git_lfs_app): params = {'oid': 'missing', 'size': '1024'} @@ -204,7 +204,7 @@ class TestLFSApplication(object): status=404) assert json.loads(response.text) == { - u'message': u'oid `missing` does not exists in store'} + 'message': 'oid `missing` does not exists in store'} def test_app_verify_api_size_mismatch(self, git_lfs_app): oid = 'existing' @@ -219,8 +219,8 @@ class TestLFSApplication(object): '/repo/info/lfs/verify', params=params, status=422) assert json.loads(response.text) == { - u'message': u'requested file size mismatch ' - u'store size:11 requested:1024'} + 'message': 'requested file size mismatch ' + 'store size:11 requested:1024'} def test_app_verify_api(self, git_lfs_app): oid = 'existing' @@ -235,7 +235,7 @@ class TestLFSApplication(object): '/repo/info/lfs/verify', params=params) assert json.loads(response.text) == { - u'message': {u'size': u'ok', u'in_store': u'ok'}} + 'message': {'size': 'ok', 'in_store': 'ok'}} def test_app_download_api_oid_not_existing(self, git_lfs_app): oid = 'missing' @@ -244,7 +244,7 @@ class TestLFSApplication(object): '/repo/info/lfs/objects/{oid}'.format(oid=oid), status=404) assert json.loads(response.text) == { - u'message': u'requested file with oid `missing` not found in store'} + 'message': 'requested file with oid `missing` not found in store'} def test_app_download_api(self, git_lfs_app): oid = 'existing' @@ -264,7 +264,7 @@ class TestLFSApplication(object): response = git_lfs_app.put( '/repo/info/lfs/objects/{oid}'.format(oid=oid), params='CONTENT') - assert json.loads(response.text) == {u'upload': u'ok'} + assert json.loads(response.text) == {'upload': 'ok'} # verify that we actually wrote that OID oid_path = os.path.join(git_lfs_app._store, oid) diff --git a/vcsserver/hgcompat.py b/vcsserver/hgcompat.py --- a/vcsserver/hgcompat.py +++ b/vcsserver/hgcompat.py @@ -78,7 +78,7 @@ def get_ctx(repo, ref): ctx = revsymbol(repo, ref) except (LookupError, RepoLookupError): # Similar case as above but only for refs that are not numeric - if isinstance(ref, (int, long)): + if isinstance(ref, int): raise ctx = revsymbol(repo, ref) return ctx diff --git a/vcsserver/hooks.py b/vcsserver/hooks.py --- a/vcsserver/hooks.py +++ b/vcsserver/hooks.py @@ -579,7 +579,7 @@ def git_post_receive(unused_repo_path, r except Exception: cmd = [settings.GIT_EXECUTABLE, 'symbolic-ref', '"HEAD"', '"refs/heads/%s"' % push_ref['name']] - print("Setting default branch to %s" % push_ref['name']) + print(("Setting default branch to %s" % push_ref['name'])) subprocessio.run_command(cmd, env=os.environ.copy()) cmd = [settings.GIT_EXECUTABLE, 'for-each-ref', diff --git a/vcsserver/lib/_vendor/statsd/__init__.py b/vcsserver/lib/_vendor/statsd/__init__.py --- a/vcsserver/lib/_vendor/statsd/__init__.py +++ b/vcsserver/lib/_vendor/statsd/__init__.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, division, unicode_literals + import logging diff --git a/vcsserver/lib/_vendor/statsd/base.py b/vcsserver/lib/_vendor/statsd/base.py --- a/vcsserver/lib/_vendor/statsd/base.py +++ b/vcsserver/lib/_vendor/statsd/base.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, division, unicode_literals + import re import random diff --git a/vcsserver/lib/_vendor/statsd/stream.py b/vcsserver/lib/_vendor/statsd/stream.py --- a/vcsserver/lib/_vendor/statsd/stream.py +++ b/vcsserver/lib/_vendor/statsd/stream.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, division, unicode_literals + import socket diff --git a/vcsserver/lib/_vendor/statsd/timer.py b/vcsserver/lib/_vendor/statsd/timer.py --- a/vcsserver/lib/_vendor/statsd/timer.py +++ b/vcsserver/lib/_vendor/statsd/timer.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, division, unicode_literals + import functools diff --git a/vcsserver/lib/_vendor/statsd/udp.py b/vcsserver/lib/_vendor/statsd/udp.py --- a/vcsserver/lib/_vendor/statsd/udp.py +++ b/vcsserver/lib/_vendor/statsd/udp.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, division, unicode_literals + import socket diff --git a/vcsserver/lib/rc_cache/backends.py b/vcsserver/lib/rc_cache/backends.py --- a/vcsserver/lib/rc_cache/backends.py +++ b/vcsserver/lib/rc_cache/backends.py @@ -265,7 +265,7 @@ class BaseRedisBackend(redis_backend.Red def get_mutex(self, key): if self.distributed_lock: - lock_key = u'_lock_{0}'.format(safe_unicode(key)) + lock_key = '_lock_{0}'.format(safe_unicode(key)) return get_mutex_lock(self.client, lock_key, self._lock_timeout, auto_renewal=self._lock_auto_renewal) else: diff --git a/vcsserver/lib/rc_cache/utils.py b/vcsserver/lib/rc_cache/utils.py --- a/vcsserver/lib/rc_cache/utils.py +++ b/vcsserver/lib/rc_cache/utils.py @@ -105,11 +105,11 @@ class RhodeCodeCacheRegion(CacheRegion): def get_or_create_for_user_func(key_generator, user_func, *arg, **kw): if not condition: - log.debug('Calling un-cached method:%s', user_func.func_name) + log.debug('Calling un-cached method:%s', user_func.__name__) start = time.time() result = user_func(*arg, **kw) total = time.time() - start - log.debug('un-cached method:%s took %.4fs', user_func.func_name, total) + log.debug('un-cached method:%s took %.4fs', user_func.__name__, total) return result key = key_generator(*arg, **kw) @@ -117,7 +117,7 @@ class RhodeCodeCacheRegion(CacheRegion): timeout = expiration_time() if expiration_time_is_callable \ else expiration_time - log.debug('Calling cached method:`%s`', user_func.func_name) + log.debug('Calling cached method:`%s`', user_func.__name__) return self.get_or_create(key, user_func, timeout, should_cache_fn, (arg, kw)) def cache_decorator(user_func): diff --git a/vcsserver/scm_app.py b/vcsserver/scm_app.py --- a/vcsserver/scm_app.py +++ b/vcsserver/scm_app.py @@ -81,7 +81,7 @@ class HgWeb(mercurial.hgweb.hgweb_mod.hg first_chunk = None try: - data = gen.next() + data = next(gen) def first_chunk(): yield data diff --git a/vcsserver/subprocessio.py b/vcsserver/subprocessio.py --- a/vcsserver/subprocessio.py +++ b/vcsserver/subprocessio.py @@ -47,7 +47,7 @@ class StreamFeeder(Thread): if type(source) in (type(''), bytes, bytearray): # string-like self.bytes = bytes(source) else: # can be either file pointer or file-like - if type(source) in (int, long): # file pointer it is + if type(source) in (int, int): # file pointer it is # converting file descriptor (int) stdin into file-like try: source = os.fdopen(source, 'rb', 16384) @@ -189,7 +189,7 @@ class BufferedGenerator(object): def __iter__(self): return self - def next(self): + def __next__(self): while not len(self.data) and not self.worker.EOF.is_set(): self.worker.data_added.clear() self.worker.data_added.wait(0.2) @@ -440,7 +440,7 @@ class SubprocessIOChunker(object): def __iter__(self): return self - def next(self): + def __next__(self): # Note: mikhail: We need to be sure that we are checking the return # code after the stdout stream is closed. Some processes, e.g. git # are doing some magic in between closing stdout and terminating the @@ -449,7 +449,7 @@ class SubprocessIOChunker(object): result = None stop_iteration = None try: - result = self.output.next() + result = next(self.output) except StopIteration as e: stop_iteration = e diff --git a/vcsserver/tests/conftest.py b/vcsserver/tests/conftest.py --- a/vcsserver/tests/conftest.py +++ b/vcsserver/tests/conftest.py @@ -39,7 +39,7 @@ def repeat(request): @pytest.fixture(scope='session') def vcsserver_port(request): port = get_available_port() - print('Using vcsserver port %s' % (port, )) + print(('Using vcsserver port %s' % (port, ))) return port diff --git a/vcsserver/tests/test_git.py b/vcsserver/tests/test_git.py --- a/vcsserver/tests/test_git.py +++ b/vcsserver/tests/test_git.py @@ -113,7 +113,7 @@ class TestReraiseSafeExceptions(object): methods = inspect.getmembers(git_remote, predicate=inspect.ismethod) for method_name, method in methods: if not method_name.startswith('_') and method_name not in ['vcsserver_invalidate_cache']: - assert method.im_func.__code__ == decorator.__code__ + assert method.__func__.__code__ == decorator.__code__ @pytest.mark.parametrize('side_effect, expected_type', [ (dulwich.errors.ChecksumMismatch('0000000', 'deadbeef'), 'lookup'), diff --git a/vcsserver/tests/test_hg.py b/vcsserver/tests/test_hg.py --- a/vcsserver/tests/test_hg.py +++ b/vcsserver/tests/test_hg.py @@ -52,7 +52,7 @@ class TestReraiseSafeExceptions(object): decorator = hg.reraise_safe_exceptions(None) for method_name, method in methods: if not method_name.startswith('_') and method_name not in ['vcsserver_invalidate_cache']: - assert method.im_func.__code__ == decorator.__code__ + assert method.__func__.__code__ == decorator.__code__ @pytest.mark.parametrize('side_effect, expected_type', [ (hgcompat.Abort(), 'abort'), diff --git a/vcsserver/tests/test_hgpatches.py b/vcsserver/tests/test_hgpatches.py --- a/vcsserver/tests/test_hgpatches.py +++ b/vcsserver/tests/test_hgpatches.py @@ -28,7 +28,7 @@ def test_patch_largefiles_capabilities_a patched_capabilities): lfproto = hgcompat.largefiles.proto hgpatches.patch_largefiles_capabilities() - assert lfproto._capabilities.func_name == '_dynamic_capabilities' + assert lfproto._capabilities.__name__ == '_dynamic_capabilities' def test_dynamic_capabilities_uses_original_function_if_not_enabled( diff --git a/vcsserver/tests/test_subprocessio.py b/vcsserver/tests/test_subprocessio.py --- a/vcsserver/tests/test_subprocessio.py +++ b/vcsserver/tests/test_subprocessio.py @@ -100,7 +100,7 @@ def test_does_not_fail_on_stderr(environ @pytest.mark.parametrize('size', [1, 10 ** 5]) def test_output_with_no_input(size, environ): - print(type(environ)) + print((type(environ))) data = 'X' args = _get_python_args('sys.stdout.write("%s" * %d)' % (data, size)) output = ''.join(subprocessio.SubprocessIOChunker(args, shell=False, env=environ)) @@ -118,7 +118,7 @@ def test_output_with_no_input_does_not_f ) ) - print("{} {}".format(len(data * size), len(output))) + print(("{} {}".format(len(data * size), len(output)))) assert output == data * size