Author: Armin Rigo <[email protected]>
Branch: gc-del
Changeset: r63663:dad9e6bc4c95
Date: 2013-04-26 21:13 +0200
http://bitbucket.org/pypy/pypy/changeset/dad9e6bc4c95/

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

diff --git a/pypy/module/cpyext/pyobject.py b/pypy/module/cpyext/pyobject.py
--- a/pypy/module/cpyext/pyobject.py
+++ b/pypy/module/cpyext/pyobject.py
@@ -10,6 +10,7 @@
 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
 
 #________________________________________________________
@@ -392,8 +393,9 @@
     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)
diff --git a/rpython/translator/backendopt/destructor.py 
b/rpython/translator/backendopt/destructor.py
--- a/rpython/translator/backendopt/destructor.py
+++ b/rpython/translator/backendopt/destructor.py
@@ -14,7 +14,8 @@
     * 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']
 
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to