diff Objects/typeobject.c @ 24251:7d0982056f72 2.2

The object returned by tp_new() may not have a tp_init. If the object is an ExtensionClass, for example, the slot is not even defined. So we must check that the type has the slot (implied by HAVE_CLASS) before calling tp_init().
author Jeremy Hylton <jeremy@alum.mit.edu>
date Tue, 16 Jul 2002 19:42:21 +0000
parents bec5b6610622
children 15ee445af07f
line wrap: on
line diff
--- a/Objects/typeobject.c	Fri Jul 12 17:15:45 2002 +0000
+++ b/Objects/typeobject.c	Tue Jul 16 19:42:21 2002 +0000
@@ -190,7 +190,8 @@
 		     (PyDict_Check(kwds) && PyDict_Size(kwds) == 0)))
 			return obj;
 		type = obj->ob_type;
-		if (type->tp_init != NULL &&
+		if (PyType_HasFeature(type, Py_TPFLAGS_HAVE_CLASS) &&
+		    type->tp_init != NULL &&
 		    type->tp_init(obj, args, kwds) < 0) {
 			Py_DECREF(obj);
 			obj = NULL;