[pypy-svn] r47576 - pypy/dist/pypy/rpython/lltypesystem

arigo at codespeak.net arigo at codespeak.net
Fri Oct 19 13:22:04 CEST 2007


Author: arigo
Date: Fri Oct 19 13:22:04 2007
New Revision: 47576

Modified:
   pypy/dist/pypy/rpython/lltypesystem/llmemory.py
Log:
for the convenience of debugging the GCs, NULL compares as the
smallest address.


Modified: pypy/dist/pypy/rpython/lltypesystem/llmemory.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/llmemory.py	(original)
+++ pypy/dist/pypy/rpython/lltypesystem/llmemory.py	Fri Oct 19 13:22:04 2007
@@ -353,7 +353,16 @@
             return NotImplemented
 
     def __lt__(self, other):
-        raise TypeError("cannot compare fakeaddresses with '<'")
+        # for the convenience of debugging the GCs, NULL compares as the
+        # smallest address even when compared with a non-fakearenaaddress
+        if not isinstance(other, fakeaddress):
+            raise TypeError("cannot compare fakeaddress and %r" % (
+                other.__class__.__name__,))
+        if not other:
+            return False     # self < NULL              => False
+        if not self:
+            return True      # NULL < non-null-other    => True
+        raise TypeError("cannot compare non-NULL fakeaddresses with '<'")
     def __le__(self, other):
         return self == other or self < other
     def __gt__(self, other):



More information about the Pypy-commit mailing list