Commits

Armin Rigo  committed dad9e6b

Fix cpyext/pyobject.py. Add an operation to destructor.py.

  • Participants
  • Parent commits 672b7f7
  • Branches gc-del

Comments (0)

Files changed (2)

File pypy/module/cpyext/pyobject.py

 from pypy.objspace.std.objectobject import W_ObjectObject
 from rpython.rlib.objectmodel import specialize, we_are_translated
 from rpython.rlib.rweakref import RWeakKeyDictionary
+from rpython.rlib import rgc
 from rpython.rtyper.annlowlevel import llhelper
 
 #________________________________________________________
     def __init__(self, space, pyo):
         self.pyo = pyo
         self.space = space
+        rgc.register_finalizer(self.finalizer)
 
-    def __del__(self):
+    def finalizer(self):
         if self.pyo:
             assert self.pyo.c_ob_refcnt == 0
             _Py_Dealloc(self.space, self.pyo)

File rpython/translator/backendopt/destructor.py

     * anything that escapes self
     * anything that can allocate
     """
-    ok_operations = ['ptr_nonzero', 'ptr_eq', 'ptr_ne', 'free', 'same_as',
+    ok_operations = ['ptr_nonzero', 'ptr_iszero', 'ptr_eq', 'ptr_ne',
+                     'free', 'same_as',
                      'direct_ptradd', 'force_cast', 'track_alloc_stop',
                      'raw_free']