[Zodb-checkins] CVS: Zope3/src/BTrees - check.py:1.7

Tim Peters tim.one at comcast.net
Tue Apr 6 17:47:43 EDT 2004

Update of /cvs-repository/Zope3/src/BTrees
In directory cvs.zope.org:/tmp/cvs-serv14114/src/BTrees

Modified Files:
Log Message:
ZODB.utils grows a new function positive_id(), which returns the id() of
an object as a non-negative integer.  Code trying to pass addresses to
an %x format uses positive_id(), and this avoids a Python FutureWarning
about applying %x to negative ints.  The primary difference between this
and the last stab is that positive_id() should work OK on 64-bit boxes
too.  What we really want here is C's %p format code, but in Python we
can't even reliably know the width of native addresses.

=== Zope3/src/BTrees/check.py 1.6 => 1.7 ===
--- Zope3/src/BTrees/check.py:1.6	Tue Apr  6 16:21:55 2004
+++ Zope3/src/BTrees/check.py	Tue Apr  6 17:47:11 2004
@@ -39,6 +39,8 @@
 from BTrees.IOBTree import IOBTree, IOBucket, IOSet, IOTreeSet
 from BTrees.IIBTree import IIBTree, IIBucket, IISet, IITreeSet
+from ZODB.utils import positive_id
 _type2kind = {IOBTree: (TYPE_BTREE, True),
@@ -198,9 +200,7 @@
     return keys, values
 def type_and_adr(obj):
-    # Force the address to look positive.  A negative address will
-    # show up as signed in Python 2.4, and in 2.3 raises FutureWarning.
-    return "%s (0x%x)" % (type(obj).__name__, id(obj) & 0xffffffffL)
+    return "%s (0x%x)" % (type(obj).__name__, positive_id(obj))
 # Walker implements a depth-first search of a BTree (or TreeSet or Set or
 # Bucket).  Subclasses must implement the visit_btree() and visit_bucket()

More information about the Zodb-checkins mailing list