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.)
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);
}