From 719841e2fbf9ca6320aa9515fe054cf4887dab64 Mon Sep 17 00:00:00 2001 From: Jeremy Hylton Date: Tue, 16 Jul 2002 19:39:38 +0000 Subject: 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(). --- Objects/typeobject.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Objects/typeobject.c b/Objects/typeobject.c index a7263d8..31a7c3d 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -199,7 +199,8 @@ type_call(PyTypeObject *type, PyObject *args, PyObject *kwds) if (!PyType_IsSubtype(obj->ob_type, type)) 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; -- cgit v0.12