[pypy-svn] r27547 - in pypy/dist/pypy/translator/c: . test

arigo at codespeak.net arigo at codespeak.net
Sun May 21 21:01:26 CEST 2006


Author: arigo
Date: Sun May 21 21:01:25 2006
New Revision: 27547

Modified:
   pypy/dist/pypy/translator/c/gc.py
   pypy/dist/pypy/translator/c/test/test_newgc.py
Log:
Fix and test for when __del__ bodies are put in the database by the
framework gc policy.



Modified: pypy/dist/pypy/translator/c/gc.py
==============================================================================
--- pypy/dist/pypy/translator/c/gc.py	(original)
+++ pypy/dist/pypy/translator/c/gc.py	Sun May 21 21:01:25 2006
@@ -352,7 +352,11 @@
     transformerclass = gctransform.FrameworkGCTransformer
 
     def struct_setup(self, structdefnode, rtti):
-        pass
+        if rtti is not None and hasattr(rtti._obj, 'destructor_funcptr'):
+            destrptr = rtti._obj.destructor_funcptr
+            # make sure this is seen by the database early, i.e. before
+            # finish() on the gctransformer
+            self.db.get(destrptr)
 
     def array_setup(self, arraydefnode):
         pass

Modified: pypy/dist/pypy/translator/c/test/test_newgc.py
==============================================================================
--- pypy/dist/pypy/translator/c/test/test_newgc.py	(original)
+++ pypy/dist/pypy/translator/c/test/test_newgc.py	Sun May 21 21:01:25 2006
@@ -625,6 +625,19 @@
         res = fn()
         assert res == 123
 
+    def test_framework_del_seeing_new_types(self):
+        class B(object):
+            pass
+        class A(object):
+            def __del__(self):
+                B()
+        def f():
+            A()
+            return 42
+        fn = self.getcompiled(f)
+        res = fn()
+        assert res == 42
+
 class TestUsingStacklessFramework(TestUsingFramework):
     from pypy.translator.c.gc import StacklessFrameworkGcPolicy as gcpolicy
 



More information about the Pypy-commit mailing list