diff --git a/src/allmydata/immutable/downloader/share.py b/src/allmydata/immutable/downloader/share.py index 7ec2935fd..15f55d409 100644 --- a/src/allmydata/immutable/downloader/share.py +++ b/src/allmydata/immutable/downloader/share.py @@ -464,7 +464,7 @@ class Share(object): # there was corruption somewhere in the given range reason = "corruption in share[%d-%d): %s" % (start, start+offset, str(f.value)) - self._rref.callRemoteOnly("advise_corrupt_share", reason) + self._rref.callRemoteOnly("advise_corrupt_share", reason.encode("utf-8")) def _satisfy_block_hash_tree(self, needed_hashes): o_bh = self.actual_offsets["block_hashes"] diff --git a/src/allmydata/mutable/retrieve.py b/src/allmydata/mutable/retrieve.py index b2d234a15..fde762d29 100644 --- a/src/allmydata/mutable/retrieve.py +++ b/src/allmydata/mutable/retrieve.py @@ -39,7 +39,7 @@ class RetrieveStatus(object): self.size = None self.status = "Not started" self.progress = 0.0 - self.counter = self.statusid_counter.next() + self.counter = next(self.statusid_counter) self.started = time.time() def get_started(self): @@ -321,7 +321,7 @@ class Retrieve(object): self._active_readers = [] # list of active readers for this dl. self._block_hash_trees = {} # shnum => hashtree - for i in xrange(self._total_shares): + for i in range(self._total_shares): # So we don't have to do this later. self._block_hash_trees[i] = hashtree.IncompleteHashTree(self._num_segments) diff --git a/src/allmydata/mutable/servermap.py b/src/allmydata/mutable/servermap.py index 8dba6d8b5..32962c495 100644 --- a/src/allmydata/mutable/servermap.py +++ b/src/allmydata/mutable/servermap.py @@ -33,7 +33,7 @@ class UpdateStatus(object): self.mode = "?" self.status = "Not started" self.progress = 0.0 - self.counter = self.statusid_counter.next() + self.counter = next(self.statusid_counter) self.started = time.time() self.finished = None diff --git a/src/allmydata/storage/server.py b/src/allmydata/storage/server.py index 14eb08f84..8a8138f26 100644 --- a/src/allmydata/storage/server.py +++ b/src/allmydata/storage/server.py @@ -697,7 +697,7 @@ class StorageServer(service.MultiService, Referenceable): # This is a remote API, I believe, so this has to be bytes for legacy # protocol backwards compatibility reasons. assert isinstance(share_type, bytes) - assert isinstance(reason, bytes) + assert isinstance(reason, bytes), "%r is not bytes" % (reason,) fileutil.make_dirs(self.corruption_advisory_dir) now = time_format.iso_utc(sep="T") si_s = si_b2a(storage_index) diff --git a/src/allmydata/test/test_download.py b/src/allmydata/test/test_download.py index a65b627d3..bbf1ab75c 100644 --- a/src/allmydata/test/test_download.py +++ b/src/allmydata/test/test_download.py @@ -1,6 +1,6 @@ from __future__ import print_function -from future.utils import bchr, bord +from future.utils import bchr # system-level upload+download roundtrip test, but using shares created from # a previous run. This asserts that the current code is capable of decoding @@ -35,7 +35,7 @@ mutable_plaintext = b"This is a moderate-sized mutable file.\n" * 10 # this chunk was generated by create_share(), written to disk, then pasted # into this file. These shares were created by 1.2.0-r3247, a version that's # probably fairly close to 1.3.0 . -#--------- BEGIN stored_shares.py -------------- +#--------- BEGIN stored_shares.py --------------r immutable_uri = b"URI:CHK:g4i6qkk7mlj4vkl5ncg6dwo73i:qcas2ebousfk3q5rkl2ncayeku52kpyse76v5yeel2t2eaa4f6ha:3:10:310" immutable_shares = { 0: { # client[0] @@ -120,7 +120,7 @@ class _Base(GridTestMixin, ShouldFailMixin): d.addCallback(lambda ignored: self.c0.create_mutable_file(mutable_plaintext)) def _created_mutable(n): - f.write('mutable_uri = "%s"\n' % n.get_uri()) + f.write('mutable_uri = b"%s"\n' % n.get_uri()) f.write('mutable_shares = {\n') si = uri.from_string(n.get_uri()).get_storage_index() si_dir = storage_index_to_dir(si) @@ -604,8 +604,8 @@ class DownloadTest(_Base, unittest.TestCase): # the share. This exercises a different code path. for s in self.c0.storage_broker.get_connected_servers(): v = s.get_version() - v1 = v["http://allmydata.org/tahoe/protocols/storage/v1"] - v1["tolerates-immutable-read-overrun"] = False + v1 = v[b"http://allmydata.org/tahoe/protocols/storage/v1"] + v1[b"tolerates-immutable-read-overrun"] = False n = self.c0.create_node_from_uri(immutable_uri) d = download_to_data(n) @@ -1138,7 +1138,7 @@ class Corruption(_Base, unittest.TestCase): def _corrupt_flip_all(self, ign, imm_uri, which): def _corruptor(s, debug=False): - return s[:which] + chr(ord(s[which:which+1])^0x01) + s[which+1:] + return s[:which] + bchr(ord(s[which:which+1])^0x01) + s[which+1:] self.corrupt_all_shares(imm_uri, _corruptor) class DownloadV2(_Base, unittest.TestCase):