For new-style classes, we can now test for tp_del instead of asking

for a __del__ attribute, to see if there's a finalizer.
This commit is contained in:
Guido van Rossum 2002-08-09 17:39:14 +00:00
parent 4aa21aa5b3
commit 4030714a93
1 changed files with 3 additions and 3 deletions

View File

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