summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-11-01 14:23:28 (GMT)
committerGuido van Rossum <guido@python.org>2001-11-01 14:23:28 (GMT)
commit8cc705eabcea0436ba51ff5eb87aafa82521d2b4 (patch)
tree0cd74cf063d071153803c8125276a584c4b39e24 /Modules
parent01a9462787c0efcd0cfef33407e99f6ef6531eb2 (diff)
downloadcpython-8cc705eabcea0436ba51ff5eb87aafa82521d2b4.zip
cpython-8cc705eabcea0436ba51ff5eb87aafa82521d2b4.tar.gz
cpython-8cc705eabcea0436ba51ff5eb87aafa82521d2b4.tar.bz2
SF bug #477059 (my own): __del__ on new classes vs. GC.
When moving objects with a __del__ attribute to a special list, look for __del__ on new-style classes with the HEAPTYPE flag set as well. (HEAPTYPE means the class was created by a class statement.)
Diffstat (limited to 'Modules')
-rw-r--r--Modules/gcmodule.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c
index 0badc23..a0522a0 100644
--- a/Modules/gcmodule.c
+++ b/Modules/gcmodule.c
@@ -241,7 +241,9 @@ move_finalizers(PyGC_Head *unreachable, PyGC_Head *finalizers)
for (; gc != unreachable; gc=next) {
PyObject *op = FROM_GC(gc);
next = gc->gc.gc_next;
- if (PyInstance_Check(op) && PyObject_HasAttr(op, delstr)) {
+ if ((PyInstance_Check(op) ||
+ PyType_HasFeature(op->ob_type, Py_TPFLAGS_HEAPTYPE)) &&
+ PyObject_HasAttr(op, delstr)) {
gc_list_remove(gc);
gc_list_append(gc, finalizers);
}