[pypy-svn] r72644 - pypy/branch/cpython-extension/pypy/module/cpyext
xoraxax at codespeak.net
xoraxax at codespeak.net
Tue Mar 23 18:10:25 CET 2010
Author: xoraxax
Date: Tue Mar 23 18:10:23 2010
New Revision: 72644
Modified:
pypy/branch/cpython-extension/pypy/module/cpyext/object.py
pypy/branch/cpython-extension/pypy/module/cpyext/typeobject.py
Log:
Implement dealloc slot of object correctly (needs to call into the free slot of the type object).
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/object.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/object.py (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/object.py Tue Mar 23 18:10:23 2010
@@ -1,6 +1,8 @@
from pypy.rpython.lltypesystem import rffi, lltype
-from pypy.module.cpyext.api import cpython_api, PyObject, make_ref, from_ref
+from pypy.module.cpyext.api import cpython_api, PyObject, make_ref, from_ref, \
+ generic_cpy_call
from pypy.module.cpyext.state import State
+from pypy.module.cpyext.macros import Py_INCREF, Py_DECREF
from pypy.module.cpyext.typeobject import PyTypeObjectPtr, W_PyCTypeObject, W_PyCObject
from pypy.objspace.std.objectobject import W_ObjectObject
@@ -19,7 +21,8 @@
lltype.free(obj, flavor='raw')
@cpython_api([PyObject], lltype.Void)
-def PyObject_Del_cast(space, obj):
- # XXX cast object according to the basesize in pto
- lltype.free(obj, flavor='raw')
+def PyObject_dealloc(space, obj):
+ pto = rffi.cast(PyTypeObjectPtr, obj.c_obj_type)
+ obj_voidp = rffi.cast(rffi.VOIDP_real, obj)
+ generic_cpy_call(space, pto.c_tp_free, obj_voidp)
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/typeobject.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/typeobject.py (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/typeobject.py Tue Mar 23 18:10:23 2010
@@ -220,9 +220,9 @@
def allocate_type_obj(space, w_type):
- from pypy.module.cpyext.object import PyObject_Del_cast, PyObject_Del
+ from pypy.module.cpyext.object import PyObject_dealloc, PyObject_Del
pto = lltype.malloc(PyTypeObject, None, flavor="raw")
- callable = PyObject_Del_cast
+ callable = PyObject_dealloc
pto.c_tp_dealloc = llhelper(callable.api_func.functype,
make_wrapper(space, callable))
callable = PyObject_Del
More information about the Pypy-commit
mailing list