[pypy-svn] r77885 - pypy/trunk/pypy/module/gc

arigo at codespeak.net arigo at codespeak.net
Wed Oct 13 17:22:16 CEST 2010


Author: arigo
Date: Wed Oct 13 17:22:14 2010
New Revision: 77885

Modified:
   pypy/trunk/pypy/module/gc/referents.py
Log:
Yet another attempt.


Modified: pypy/trunk/pypy/module/gc/referents.py
==============================================================================
--- pypy/trunk/pypy/module/gc/referents.py	(original)
+++ pypy/trunk/pypy/module/gc/referents.py	Wed Oct 13 17:22:14 2010
@@ -15,12 +15,16 @@
 
 def try_cast_gcref_to_w_root(gcref):
     w_obj = rgc.try_cast_gcref_to_instance(W_Root, gcref)
-    # Ignore instances of exactly the class W_Root.  Seems that
-    # we get one on 64-bit translations, for some reason.
-    if w_obj is not None and type(w_obj) is W_Root:
-        w_obj = None
-    if not we_are_translated() and not hasattr(w_obj, 'typedef'):
-        w_obj = None
+    # Ignore the instances of W_Root that are not really valid as Python
+    # objects.  There is e.g. WeakrefLifeline in module/_weakref that
+    # inherits from W_Root for internal reasons.  Such instances don't
+    # have a typedef at all (or have a null typedef after translation).
+    if not we_are_translated():
+        if not hasattr(w_obj, 'typedef'):
+            return None
+    else:
+        if w_obj is None or not w_obj.typedef:
+            return None
     return w_obj
 
 def wrap(space, gcref):



More information about the Pypy-commit mailing list