From 02acd9d2ebcddd337449be5a2bcf45780f7c15ed Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Tue, 29 Sep 2020 13:47:27 -0400 Subject: [PATCH 1/3] News file. --- newsfragments/3453.minor | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 newsfragments/3453.minor diff --git a/newsfragments/3453.minor b/newsfragments/3453.minor new file mode 100644 index 000000000..e69de29bb From 206f25d87eff0d06281ed6113a23994ff3e74168 Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Tue, 29 Sep 2020 13:50:59 -0400 Subject: [PATCH 2/3] Port to Python 3. --- src/allmydata/immutable/downloader/share.py | 11 +++++++++++ src/allmydata/util/_python3.py | 1 + 2 files changed, 12 insertions(+) diff --git a/src/allmydata/immutable/downloader/share.py b/src/allmydata/immutable/downloader/share.py index 15f55d409..f279018ba 100644 --- a/src/allmydata/immutable/downloader/share.py +++ b/src/allmydata/immutable/downloader/share.py @@ -1,3 +1,14 @@ +""" +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 +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 struct import time diff --git a/src/allmydata/util/_python3.py b/src/allmydata/util/_python3.py index ce9cf353d..c93c27b32 100644 --- a/src/allmydata/util/_python3.py +++ b/src/allmydata/util/_python3.py @@ -33,6 +33,7 @@ PORTED_MODULES = [ "allmydata.crypto.util", "allmydata.hashtree", "allmydata.immutable.happiness_upload", + "allmydata.immutable.downloader.share", "allmydata.interfaces", "allmydata.introducer.interfaces", "allmydata.monitor", From 2fae4b06bf40a37f709dae1d16769b3cc6f8b677 Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Wed, 30 Sep 2020 14:12:48 -0400 Subject: [PATCH 3/3] Fix Python 2 tests. --- src/allmydata/immutable/downloader/share.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/allmydata/immutable/downloader/share.py b/src/allmydata/immutable/downloader/share.py index f279018ba..261ed79e1 100644 --- a/src/allmydata/immutable/downloader/share.py +++ b/src/allmydata/immutable/downloader/share.py @@ -6,7 +6,7 @@ from __future__ import division from __future__ import print_function from __future__ import unicode_literals -from future.utils import PY2 +from future.utils import PY2, native_str 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 @@ -765,7 +765,9 @@ class Share(object): level=log.WEIRD, umid="qZu0wg")) def _send_request(self, start, length): - return self._rref.callRemote("read", start, length) + # For some reason tests fail on Python 2 if this is not a native + # string... + return self._rref.callRemote(native_str("read"), start, length) def _got_data(self, data, start, length, block_ev, lp): block_ev.finished(len(data), now())