diff Modules/gcmodule.c @ 24714:74143db6ae2f legacy-trunk

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.
author Guido van Rossum <guido@python.org>
date Fri, 09 Aug 2002 17:39:14 +0000
parents d332484e394a
children 4ab6b7c3f311
line wrap: on
line diff
--- a/Modules/gcmodule.c	Fri Aug 09 17:38:16 2002 +0000
+++ b/Modules/gcmodule.c	Fri Aug 09 17:39:14 2002 +0000
@@ -346,9 +346,9 @@
 		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__) */