]> granicus.if.org Git - python/commitdiff
SF bug #477059 (my own): __del__ on new classes vs. GC.
authorGuido van Rossum <guido@python.org>
Thu, 1 Nov 2001 14:23:28 +0000 (14:23 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 1 Nov 2001 14:23:28 +0000 (14:23 +0000)
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.)

Modules/gcmodule.c

index 0badc23a4d3404794cff02e6e9106908efab5fc9..a0522a095242bf13bb9b85f0f66a8214f938024e 100644 (file)
@@ -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);
                }