Skip to content

Commit

Permalink
Py3.2: don't rely on binascii.unhexlify to convert under covers.
Browse files Browse the repository at this point in the history
  • Loading branch information
tseaver committed Mar 3, 2013
1 parent fd0d2b0 commit 257fed3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/ZODB/blob.py
Expand Up @@ -557,7 +557,7 @@ def oid_to_path(self, oid):
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 = path.split(os.path.sep)
path = [bytes(x, 'ascii') 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)
Expand Down
4 changes: 3 additions & 1 deletion src/ZODB/utils.py
Expand Up @@ -164,7 +164,9 @@ def oid_repr(oid):
return repr(oid)

def repr_to_oid(repr):
if repr.startswith("0x"):
if not isinstance(repr, bytes):
repr = bytes(repr, 'ascii')
if repr.startswith(b"0x"):
repr = repr[2:]
as_bin = unhexlify(repr)
as_bin = b"\x00"*(8-len(as_bin)) + as_bin
Expand Down

0 comments on commit 257fed3

Please sign in to comment.