diff --git a/src/allmydata/storage/server.py b/src/allmydata/storage/server.py index e36e4a2f1..845d3ac1a 100644 --- a/src/allmydata/storage/server.py +++ b/src/allmydata/storage/server.py @@ -6,10 +6,11 @@ from __future__ import absolute_import from __future__ import print_function from __future__ import unicode_literals -from future.utils import bytes_to_native_str, PY2 +from future.utils import bytes_to_native_str, PY2, native_str_to_bytes if PY2: - # Omit open() to get native behavior where open("w") always accepts native strings. - from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401 + # Omit open() to get native behavior where open("w") always accepts native + # strings. Omit bytes so we don't leak future's custom bytes. + from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, pow, round, super, dict, list, object, range, str, max, min # noqa: F401 import os, re, struct, time @@ -241,16 +242,18 @@ class StorageServer(service.MultiService, Referenceable): # We're on a platform that has no API to get disk stats. remaining_space = 2**64 - version = { "http://allmydata.org/tahoe/protocols/storage/v1" : - { "maximum-immutable-share-size": remaining_space, - "maximum-mutable-share-size": MAX_MUTABLE_SHARE_SIZE, - "available-space": remaining_space, - "tolerates-immutable-read-overrun": True, - "delete-mutable-shares-with-zero-length-writev": True, - "fills-holes-with-zero-bytes": True, - "prevents-read-past-end-of-share-data": True, + # Unicode strings might be nicer, but for now sticking to bytes since + # this is what the wire protocol has always been. + version = { b"http://allmydata.org/tahoe/protocols/storage/v1" : + { b"maximum-immutable-share-size": remaining_space, + b"maximum-mutable-share-size": MAX_MUTABLE_SHARE_SIZE, + b"available-space": remaining_space, + b"tolerates-immutable-read-overrun": True, + b"delete-mutable-shares-with-zero-length-writev": True, + b"fills-holes-with-zero-bytes": True, + b"prevents-read-past-end-of-share-data": True, }, - "application-version": str(allmydata.__full_version__), + b"application-version": allmydata.__full_version__.encode("utf-8"), } return version diff --git a/src/allmydata/test/test_deepcheck.py b/src/allmydata/test/test_deepcheck.py index 90a27b424..ea3ba6338 100644 --- a/src/allmydata/test/test_deepcheck.py +++ b/src/allmydata/test/test_deepcheck.py @@ -1,3 +1,4 @@ +from future.utils import native_str import os, json, urllib from twisted.trial import unittest @@ -945,7 +946,7 @@ class DeepCheckWebBad(DeepCheckBase, unittest.TestCase): def _corrupt_some_shares(self, node): for (shnum, serverid, sharefile) in self.find_uri_shares(node.get_uri()): if shnum in (0,1): - yield run_cli("debug", "corrupt-share", sharefile) + yield run_cli("debug", "corrupt-share", native_str(sharefile)) def _delete_most_shares(self, node): self.delete_shares_numbered(node.get_uri(), range(1,10))