]> granicus.if.org Git - python/commitdiff
For new-style classes, we can now test for tp_del instead of asking
authorGuido van Rossum <guido@python.org>
Fri, 9 Aug 2002 17:39:14 +0000 (17:39 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 9 Aug 2002 17:39:14 +0000 (17:39 +0000)
for a __del__ attribute, to see if there's a finalizer.

Modules/gcmodule.c

index e0c763173c6ae1ae79c01b8ad5d2c6595ac0f854..bae265389d1c377014bdabc062c638fb626bdb9e 100644 (file)
@@ -346,9 +346,9 @@ has_finalizer(PyObject *op)
                if (delstr == NULL)
                        Py_FatalError("PyGC: can't initialize __del__ string");
        }
-       return (PyInstance_Check(op) ||
-               PyType_HasFeature(op->ob_type, Py_TPFLAGS_HEAPTYPE))
-              && PyObject_HasAttr(op, delstr);
+       return PyInstance_Check(op) ? PyObject_HasAttr(op, delstr) :
+               PyType_HasFeature(op->ob_type, Py_TPFLAGS_HEAPTYPE) ?
+               op->ob_type->tp_del != NULL : 0;
 }
 
 /* Move all objects with finalizers (instances with __del__) */