[pypy-svn] r79733 - pypy/branch/psycopg2compatibility/pypy/module/cpyext

dan at codespeak.net dan at codespeak.net
Thu Dec 2 03:30:52 CET 2010


Author: dan
Date: Thu Dec  2 03:30:50 2010
New Revision: 79733

Modified:
   pypy/branch/psycopg2compatibility/pypy/module/cpyext/pyobject.py
Log:
Beat the refcount logging code until it looked pretty in conjunction with the rest of CPyExt logging.

Modified: pypy/branch/psycopg2compatibility/pypy/module/cpyext/pyobject.py
==============================================================================
--- pypy/branch/psycopg2compatibility/pypy/module/cpyext/pyobject.py	(original)
+++ pypy/branch/psycopg2compatibility/pypy/module/cpyext/pyobject.py	Thu Dec  2 03:30:50 2010
@@ -250,13 +250,16 @@
 class InvalidPointerException(Exception):
     pass
 
-DEBUG_REFCOUNT = False
+DEBUG_REFCOUNT = True
 
 def debug_refcount(*args, **kwargs):
+    from pypy.module.cpyext.api import cpy_logger
     frame_stackdepth = kwargs.pop("frame_stackdepth", 2)
     assert not kwargs
     frame = sys._getframe(frame_stackdepth)
-    print >>sys.stderr, "%25s" % (frame.f_code.co_name, ),
+    sys.stderr.write(cpy_logger.get_indent_string())
+    sys.stderr.write(frame.f_code.co_name)
+    sys.stderr.write(' ')
     for arg in args:
         print >>sys.stderr, arg,
     print >>sys.stderr
@@ -291,7 +294,10 @@
     if DEBUG_REFCOUNT:
         debug_refcount("MAKREF", py_obj, w_obj)
         if not replace:
-            assert w_obj not in state.py_objects_w2r
+            if not we_are_translated():
+                assert w_obj not in state.py_objects_w2r, "%r shouldn't be tracked already" % w_obj
+            else:
+                assert w_obj not in state.py_objects_w2r
         assert ptr not in state.py_objects_r2w
         assert ptr not in state.borrowed_objects
     state.py_objects_w2r[w_obj] = py_obj



More information about the Pypy-commit mailing list