[pypy-svn] r73512 - in pypy/branch/cpython-extension/pypy/module/cpyext: . test
xoraxax at codespeak.net
xoraxax at codespeak.net
Wed Apr 7 18:51:34 CEST 2010
Author: xoraxax
Date: Wed Apr 7 18:51:31 2010
New Revision: 73512
Modified:
pypy/branch/cpython-extension/pypy/module/cpyext/pyobject.py
pypy/branch/cpython-extension/pypy/module/cpyext/test/test_cpyext.py
Log:
Remove borrowed objects from the dict when they are deallocated and decref them in tests in case they are still alive after running the test.
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/pyobject.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/pyobject.py (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/pyobject.py Wed Apr 7 18:51:31 2010
@@ -163,6 +163,10 @@
if obj.c_ob_refcnt == 0:
state = space.fromcache(State)
ptr = rffi.cast(ADDR, obj)
+ try:
+ del state.borrowed_objects[ptr]
+ except KeyError:
+ pass
if ptr not in state.py_objects_r2w:
w_type = from_ref(space, rffi.cast(PyObject, obj.c_ob_type))
if space.is_w(w_type, space.w_str) or space.is_w(w_type, space.w_unicode):
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/test/test_cpyext.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/test/test_cpyext.py (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/test/test_cpyext.py Wed Apr 7 18:51:31 2010
@@ -196,6 +196,12 @@
for w_obj in state.non_heaptypes:
Py_DecRef(self.space, w_obj)
state.non_heaptypes[:] = []
+ while state.borrowed_objects:
+ addr = state.borrowed_objects.keys()[0]
+ w_obj = state.py_objects_r2w[addr]
+ Py_DecRef(self.space, w_obj)
+ state.borrowed_objects = {}
+ state.borrow_mapping = {}
except OperationError:
pass
except AttributeError:
More information about the Pypy-commit
mailing list