Commits

Armin Rigo committed dbfb39c

Oups. Revert the previous change and document why it was wrong

Comments (0)

Files changed (2)

rpython/rlib/rgc.py

     return intmask(id(Class))
 
 def cast_gcref_to_int(gcref):
+    # This is meant to be used on cast_instance_to_gcref results.
+    # Don't use this on regular gcrefs obtained e.g. with
+    # lltype.cast_opaque_ptr().
     if we_are_translated():
         return lltype.cast_ptr_to_int(gcref)
     else:
-        from rpython.rtyper.lltypesystem.ll2ctypes import _llgcopaque
-        if isinstance(gcref._obj, _llgcopaque):
-            from rpython.rtyper.lltypesystem import rffi
-            return rffi.cast(lltype.Signed, gcref)
         return id(gcref._x)
 
 def dump_rpy_heap(fd):

rpython/rlib/test/test_rgc.py

     x1 = X()
     n = rgc.get_rpy_memory_usage(rgc.cast_instance_to_gcref(x1))
     assert n >= 8 and n <= 64
-
-def test_cast_gcref_to_int():
-    from rpython.rtyper.lltypesystem import rffi
-    x = rffi.cast(llmemory.GCREF, 123456)
-    assert rgc.cast_gcref_to_int(x) == 123456