This is an automated email from the ASF dual-hosted git repository. kentontaylor pushed a commit to branch kt/8415 in repository https://gitbox.apache.org/repos/asf/allura.git
commit 8b7f3a7d2f2a2a355144d4c982f29e4f3ae9248d Author: Kenton Taylor <[email protected]> AuthorDate: Thu Feb 24 17:06:06 2022 +0000 [#8415] py2 removal - removal of six.PY2 checks --- Allura/allura/lib/custom_middleware.py | 4 ++-- Allura/allura/lib/utils.py | 2 +- Allura/allura/model/auth.py | 3 +-- Allura/allura/model/project.py | 5 ----- Allura/allura/tests/functional/test_admin.py | 2 +- Allura/allura/tests/functional/test_root.py | 3 --- AlluraTest/alluratest/validation.py | 8 -------- 7 files changed, 5 insertions(+), 22 deletions(-) diff --git a/Allura/allura/lib/custom_middleware.py b/Allura/allura/lib/custom_middleware.py index 503881d..3a5ca4c 100644 --- a/Allura/allura/lib/custom_middleware.py +++ b/Allura/allura/lib/custom_middleware.py @@ -342,9 +342,9 @@ class AlluraTimerMiddleware(TimerMiddleware): Timer('repo.LastCommit.{method_name}', allura.model.repository.LastCommit, '*'), Timer('repo.Tree.{method_name}', allura.model.repository.Tree, '*'), - Timer('socket_read', socket._fileobject if six.PY2 else socket.SocketIO, 'read', 'readline', + Timer('socket_read', socket.SocketIO, 'read', 'readline', 'readlines', debug_each_call=False), - Timer('socket_write', socket._fileobject if six.PY2 else socket.SocketIO, 'write', 'writelines', + Timer('socket_write', socket.SocketIO, 'write', 'writelines', 'flush', debug_each_call=False), Timer('solr', pysolr.Solr, 'add', 'delete', 'search', 'commit'), Timer('urlopen', urlopen_pkg, 'urlopen'), diff --git a/Allura/allura/lib/utils.py b/Allura/allura/lib/utils.py index e6ddc51..987e497 100644 --- a/Allura/allura/lib/utils.py +++ b/Allura/allura/lib/utils.py @@ -223,7 +223,7 @@ class AntiSpam: self.spinner_text = request.params['spinner'] self.timestamp = int(self.timestamp_text) self.spinner = self._unwrap(self.spinner_text) - trans_fn = ord if six.PY2 else int + trans_fn = int self.spinner_ord = list(map(trans_fn, self.spinner)) self.random_padding = [random.randint(0, 255) for x in self.spinner] self.honey_class = self.enc(self.spinner_text, css_safe=True) diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py index f188962..3dda3ba 100644 --- a/Allura/allura/model/auth.py +++ b/Allura/allura/model/auth.py @@ -835,8 +835,7 @@ class User(MappedClass, ActivityNode, ActivityObject, SearchIndexable): def email_address_header(self): h = header.Header() - h.append('"{}"{}'.format(self.get_pref('display_name'), - ' ' if six.PY2 else '')) # py2 needs explicit space for unicode/text_type cast of Header + h.append('"{}"{}'.format(self.get_pref('display_name'), '')) h.append('<%s>' % self.get_pref('email_address')) return h diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py index b994c60..0e35ae3 100644 --- a/Allura/allura/model/project.py +++ b/Allura/allura/model/project.py @@ -1163,11 +1163,6 @@ class Project(SearchIndexable, MappedClass, ActivityNode, ActivityObject): shortname = self.shortname.split('/')[1] filename_format = config['bulk_export_filename'] - if six.PY2: - # in py3 ConfigParser requires %% to escape literal "%" - # since % has interpolation meaning within ConfigParser - # but in py2 the "%%" stays as "%%" so we have to switch it back to a single one - filename_format = filename_format.replace('%%', '%') return filename_format.format(project=shortname, date=datetime.utcnow()) def bulk_export_status(self): diff --git a/Allura/allura/tests/functional/test_admin.py b/Allura/allura/tests/functional/test_admin.py index 287e121..8ab03d1 100644 --- a/Allura/allura/tests/functional/test_admin.py +++ b/Allura/allura/tests/functional/test_admin.py @@ -165,7 +165,7 @@ class TestProjectAdmin(TestController): def test_features(self): proj = M.Project.query.get(shortname='test') assert_equals(proj.features, []) - with audits(r"change project features to \[{u}'One', {u}'Two'\]".format(u='u' if six.PY2 else '')): + with audits(r"change project features to \[{u}'One', {u}'Two'\]".format(u='')): resp = self.app.post('/admin/update', params={ 'features-0.feature': 'One', 'features-1.feature': ' ', diff --git a/Allura/allura/tests/functional/test_root.py b/Allura/allura/tests/functional/test_root.py index ddfaf98..97e9189 100644 --- a/Allura/allura/tests/functional/test_root.py +++ b/Allura/allura/tests/functional/test_root.py @@ -100,9 +100,6 @@ class TestRootController(TestController): self.app.get('/', headers=dict(Accept=str(hdr)), validate_skip=True) def test_encoded_urls(self): - if six.PY2: - # not valid unicode - self.app.get(b'/foo\xFF', status=400) self.app.get('/foo%FF', status=400) # encoded self.app.get('/foo%C3%A9', status=404) diff --git a/AlluraTest/alluratest/validation.py b/AlluraTest/alluratest/validation.py index 7761944..df838e9 100644 --- a/AlluraTest/alluratest/validation.py +++ b/AlluraTest/alluratest/validation.py @@ -273,14 +273,6 @@ class PostParamCheckingTestApp(AntiSpamTestApp): raise TypeError( '%s key %s has value %s of type %s, not str. ' % (method, k, v, type(v))) - elif six.PY2 and isinstance(v, str): - try: - v.encode('ascii') - #pass - except UnicodeEncodeError: - raise TypeError( - '%s key "%s" has value "%s" of type %s, should be utf-8 encoded. ' % - (method, k, v, type(v))) def get(self, *args, **kwargs): params = None
