[Zodb-checkins] CVS: Packages/ZODB - utils.py:1.17.4.2
Tim Peters
tim.one at comcast.net
Tue Aug 17 15:23:48 EDT 2004
Update of /cvs-repository/Packages/ZODB
In directory cvs.zope.org:/tmp/cvs-serv2043/ZODB
Modified Files:
Tag: Zope-2_7-branch
utils.py
Log Message:
oid_repr(): Make it obvious which base is intended. The output was
3-way ambiguous.
=== Packages/ZODB/utils.py 1.17.4.1 => 1.17.4.2 ===
--- Packages/ZODB/utils.py:1.17.4.1 Mon Sep 15 17:26:56 2003
+++ Packages/ZODB/utils.py Tue Aug 17 15:23:47 2004
@@ -17,6 +17,7 @@
from struct import pack, unpack
from types import StringType
+from binascii import hexlify
z64 = '\0'*8
t32 = 1L << 32
@@ -91,7 +92,14 @@
def oid_repr(oid):
if isinstance(oid, StringType) and len(oid) == 8:
- return '%016x' % U64(oid)
+ # Convert to hex and strip leading zeroes.
+ as_hex = hexlify(oid).lstrip('0')
+ # Ensure two characters per input byte.
+ if len(as_hex) & 1:
+ as_hex = '0' + as_hex
+ elif as_hex == '':
+ as_hex = '00'
+ return '0x' + as_hex
else:
return repr(oid)
More information about the Zodb-checkins
mailing list