Author: Matti Picus <[email protected]>
Branch: cpyext-refactor-tp_dealloc
Changeset: r91987:23ec069ceb74
Date: 2017-07-28 13:24 +0300
http://bitbucket.org/pypy/pypy/changeset/23ec069ceb74/
Log: toggle check_leaks, c_tp_dict is collected but makeGetSet is
creating immortal objects
leakcheck fails test in test_structseq.py
diff --git a/pypy/module/cpyext/test/test_cpyext.py
b/pypy/module/cpyext/test/test_cpyext.py
--- a/pypy/module/cpyext/test/test_cpyext.py
+++ b/pypy/module/cpyext/test/test_cpyext.py
@@ -102,7 +102,7 @@
'itertools', 'time', 'binascii',
'micronumpy', 'mmap'
])
- check_leaks = False
+ check_leaks = True
def cleanup(self):
self.space.getexecutioncontext().cleanup_cpyext_state()
diff --git a/pypy/module/cpyext/test/test_dictobject.py
b/pypy/module/cpyext/test/test_dictobject.py
--- a/pypy/module/cpyext/test/test_dictobject.py
+++ b/pypy/module/cpyext/test/test_dictobject.py
@@ -255,6 +255,7 @@
])
d = module.get_type_dict(1)
assert d['real'].__get__(1, 1) == 1
+
def test_advanced(self):
module = self.import_extension('foo', [
("dict_len", "METH_O",
diff --git a/pypy/module/cpyext/typeobject.py b/pypy/module/cpyext/typeobject.py
--- a/pypy/module/cpyext/typeobject.py
+++ b/pypy/module/cpyext/typeobject.py
@@ -154,6 +154,7 @@
make_typedescr(W_GetSetPropertyEx.typedef,
basestruct=PyGetSetDescrObject.TO,
attach=getsetdescr_attach,
+ dealloc=getsetdescr_dealloc,
)
make_typedescr(W_PyCClassMethodObject.typedef,
basestruct=PyMethodDescrObject.TO,
@@ -199,6 +200,13 @@
assert isinstance(w_obj, W_GetSetPropertyEx)
py_getsetdescr.c_d_getset = w_obj.getset
+@slot_function([PyObject], lltype.Void)
+def getsetdescr_dealloc(space, obj):
+ from pypy.module.cpyext.object import _dealloc
+ py_getsetdescr = rffi.cast(PyGetSetDescrObject, obj)
+ xxx
+ _dealloc(space, obj)
+
def methoddescr_attach(space, py_obj, w_obj, w_userdata=None):
py_methoddescr = rffi.cast(PyMethodDescrObject, py_obj)
# XXX assign to d_dname, d_type?
@@ -655,7 +663,7 @@
Py_DecRef(space, obj_pto.c_tp_bases)
#Py_DecRef(space, obj_pto.c_tp_mro)
Py_DecRef(space, obj_pto.c_tp_cache) # let's do it like cpython
- #Py_DecRef(space, obj_pto.c_tp_dict)
+ Py_DecRef(space, obj_pto.c_tp_dict)
if obj_pto.c_tp_flags & Py_TPFLAGS_HEAPTYPE:
heaptype = rffi.cast(PyHeapTypeObject, obj)
Py_DecRef(space, heaptype.c_ht_name)
@@ -930,10 +938,10 @@
if w_obj.is_cpytype():
Py_DecRef(space, pto.c_tp_dict)
- #w_dict = w_obj.getdict(space)
+ w_dict = w_obj.getdict(space)
# pass in the w_obj to convert any values that are
# unbound GetSetProperty into bound PyGetSetDescrObject
- #pto.c_tp_dict = make_ref(space, w_dict, w_obj)
+ pto.c_tp_dict = make_ref(space, w_dict, w_obj)
@cpython_api([PyTypeObjectPtr, PyTypeObjectPtr], rffi.INT_real,
error=CANNOT_FAIL)
def PyType_IsSubtype(space, a, b):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit