diff --git a/src/allmydata/check_results.py b/src/allmydata/check_results.py index 068f77a25..f33c3afc0 100644 --- a/src/allmydata/check_results.py +++ b/src/allmydata/check_results.py @@ -1,3 +1,4 @@ +from past.builtins import unicode from zope.interface import implementer from allmydata.interfaces import ICheckResults, ICheckAndRepairResults, \ @@ -56,7 +57,11 @@ class CheckResults(object): self._list_incompatible_shares = list_incompatible_shares self._count_incompatible_shares = count_incompatible_shares - assert isinstance(summary, str) # should be a single string + # On Python 2, we can mix bytes and Unicode. On Python 3, we want + # unicode. + if isinstance(summary, bytes): + summary = unicode(summary, "utf-8") + assert isinstance(summary, unicode) # should be a single string self._summary = summary assert not isinstance(report, str) # should be list of strings self._report = report diff --git a/src/allmydata/test/test_checker.py b/src/allmydata/test/test_checker.py index 0d5877abe..e8f7e3ce1 100644 --- a/src/allmydata/test/test_checker.py +++ b/src/allmydata/test/test_checker.py @@ -1,5 +1,16 @@ +""" +Ported to Python 3. +""" + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function +from __future__ import unicode_literals + from future.utils import PY2 -from past.builtins import unicode +if PY2: + from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401 + import json import os.path, shutil @@ -161,7 +172,7 @@ class WebResultsRendering(unittest.TestCase): "service-name": "storage", "anonymous-storage-FURL": furl, "permutation-seed-base32": "", - "nickname": unicode(nickname), + "nickname": str(nickname), "app-versions": {}, # need #466 and v2 introducer "my-version": "ver", "oldest-supported": "oldest", @@ -671,7 +682,7 @@ class BalancingAct(GridTestMixin, unittest.TestCase): "This little printing function is only meant for < 26 servers" shares_chart = {} names = dict(zip([ss.my_nodeid - for _,ss in self.g.servers_by_number.iteritems()], + for _,ss in self.g.servers_by_number.items()], letters)) for shnum, serverid, _ in self.find_uri_shares(uri): shares_chart.setdefault(shnum, []).append(names[serverid]) diff --git a/src/allmydata/util/_python3.py b/src/allmydata/util/_python3.py index 7ca18da15..f88f4f489 100644 --- a/src/allmydata/util/_python3.py +++ b/src/allmydata/util/_python3.py @@ -89,6 +89,7 @@ PORTED_TEST_MODULES = [ "allmydata.test.test_abbreviate", "allmydata.test.test_base32", "allmydata.test.test_base62", + "allmydata.test.test_checker", "allmydata.test.test_codec", "allmydata.test.test_common_util", "allmydata.test.test_configutil",