Commit 78619a38 authored by Tres Seaver's avatar Tres Seaver

Whack dem moles.

parent 257fed3f
......@@ -80,3 +80,13 @@ except NameError:
# Py3
long = int
try:
TEXT = unicode
except NameError: #pragma NO COVER Py3k
TEXT = str
def ascii_bytes(x):
if isinstance(x, TEXT):
x = x.encode('ascii')
return x
......@@ -31,7 +31,10 @@ import ZODB.interfaces
from ZODB.interfaces import BlobError
from ZODB import utils
from ZODB.POSException import POSKeyError
from ZODB._compat import BytesIO, Unpickler, decodebytes
from ZODB._compat import BytesIO
from ZODB._compat import Unpickler
from ZODB._compat import decodebytes
from ZODB._compat import ascii_bytes
if sys.version_info[0] >= 3:
......@@ -557,7 +560,7 @@ class BushyLayout(object):
def path_to_oid(self, path):
if self.blob_path_pattern.match(path) is None:
raise ValueError("Not a valid OID path: `%s`" % path)
path = [bytes(x, 'ascii') for x in path.split(os.path.sep)]
path = [ascii_bytes(x) for x in path.split(os.path.sep)]
# Each path segment stores a byte in hex representation. Turn it into
# an int and then get the character for our byte string.
oid = b''.join(binascii.unhexlify(byte[2:]) for byte in path)
......
......@@ -22,7 +22,9 @@ from tempfile import mkstemp
from persistent.TimeStamp import TimeStamp
from ZODB._compat import Unpickler, BytesIO
from ZODB._compat import Unpickler
from ZODB._compat import BytesIO
from ZODB._compat import ascii_bytes
__all__ = ['z64',
......@@ -164,8 +166,7 @@ def oid_repr(oid):
return repr(oid)
def repr_to_oid(repr):
if not isinstance(repr, bytes):
repr = bytes(repr, 'ascii')
repr = ascii_bytes(repr)
if repr.startswith(b"0x"):
repr = repr[2:]
as_bin = unhexlify(repr)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment