Changeset 5384768 in trunk
- Timestamp:
- 2020-08-07T17:08:53Z (5 years ago)
- Branches:
- master
- Children:
- 43e36eb
- Parents:
- 7516a55
- Location:
- src/allmydata
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/allmydata/codec.py ¶
r7516a55 r5384768 1 # -*- test-case-name: allmydata.test.test_encode_share -*- 1 """ 2 CRS encoding and decoding. 3 4 Ported to Python 3. 5 """ 6 from __future__ import absolute_import 7 from __future__ import division 8 from __future__ import print_function 9 from __future__ import unicode_literals 10 11 from future.utils import PY2 12 if PY2: 13 from 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 14 from future.utils import native_str 2 15 3 16 from zope.interface import implementer … … 28 41 29 42 def get_serialized_params(self): 30 return "%d-%d-%d" % (self.data_size, self.required_shares,31 self.max_shares)43 return native_str("%d-%d-%d" % (self.data_size, self.required_shares, 44 self.max_shares)) 32 45 33 46 def get_block_size(self): … … 38 51 39 52 if desired_share_ids is None: 40 desired_share_ids = range(self.max_shares)53 desired_share_ids = list(range(self.max_shares)) 41 54 42 55 for inshare in inshares: -
TabularUnified src/allmydata/test/test_codec.py ¶
r7516a55 r5384768 1 """ 2 Tests for allmydata.codec. 3 4 Ported to Python 3. 5 """ 6 from __future__ import absolute_import 7 from __future__ import division 8 from __future__ import print_function 9 from __future__ import unicode_literals 10 11 from future.utils import PY2 12 if PY2: 13 from 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 1 14 2 15 import os … … 24 37 if fewer_shares is not None: 25 38 # also validate that the desired_shareids= parameter works 26 desired_shareids = random.sample( range(max_shares), fewer_shares)39 desired_shareids = random.sample(list(range(max_shares)), fewer_shares) 27 40 d.addCallback(lambda res: enc.encode(data0s, desired_shareids)) 28 41 def _check_fewer_shares(some_shares_and_their_shareids): … … 39 52 40 53 def _check_data(decoded_shares): 41 self.failUnlessEqual(len( ''.join(decoded_shares)), len(''.join(data0s)))54 self.failUnlessEqual(len(b''.join(decoded_shares)), len(b''.join(data0s))) 42 55 self.failUnlessEqual(len(decoded_shares), len(data0s)) 43 56 for (i, (x, y)) in enumerate(zip(data0s, decoded_shares)): 44 57 self.failUnlessEqual(x, y, "%s: %r != %r.... first share was %r" % (str(i), x, y, data0s[0],)) 45 self.failUnless( ''.join(decoded_shares) ==''.join(data0s), "%s" % ("???",))58 self.failUnless(b''.join(decoded_shares) == b''.join(data0s), "%s" % ("???",)) 46 59 # 0data0sclipped = tuple(data0s) 47 60 # data0sclipped[-1] = … … 60 73 log.msg("_decode_some_random") 61 74 # use a randomly-selected minimal subset 62 l = random.sample( zip(self.shares, self.shareids), required_shares)75 l = random.sample(list(zip(self.shares, self.shareids)), required_shares) 63 76 some_shares = [ x[0] for x in l ] 64 77 some_shareids = [ x[1] for x in l ] … … 71 84 # make sure we can re-use the decoder object 72 85 shares1 = random.sample(self.shares, required_shares) 73 sharesl1 = random.sample( zip(self.shares, self.shareids), required_shares)86 sharesl1 = random.sample(list(zip(self.shares, self.shareids)), required_shares) 74 87 shares1 = [ x[0] for x in sharesl1 ] 75 88 shareids1 = [ x[1] for x in sharesl1 ] 76 sharesl2 = random.sample( zip(self.shares, self.shareids), required_shares)89 sharesl2 = random.sample(list(zip(self.shares, self.shareids)), required_shares) 77 90 shares2 = [ x[0] for x in sharesl2 ] 78 91 shareids2 = [ x[1] for x in sharesl2 ] -
TabularUnified src/allmydata/util/_python3.py ¶
r7516a55 r5384768 16 16 # Keep these sorted alphabetically, to reduce merge conflicts: 17 17 PORTED_MODULES = [ 18 "allmydata.codec", 18 19 "allmydata.crypto", 19 20 "allmydata.crypto.aes", … … 52 53 "allmydata.test.test_base32", 53 54 "allmydata.test.test_base62", 55 "allmydata.test.test_codec", 54 56 "allmydata.test.test_crypto", 55 57 "allmydata.test.test_deferredutil",
Note: See TracChangeset
for help on using the changeset viewer.