]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
The object returned by tp_new() may not have a tp_init.
authorJeremy Hylton <jeremy@alum.mit.edu>
Tue, 16 Jul 2002 19:42:21 +0000 (19:42 +0000)
committerJeremy Hylton <jeremy@alum.mit.edu>
Tue, 16 Jul 2002 19:42:21 +0000 (19:42 +0000)
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

index e8c7ea7aef512ba875abc2046bf760475b77e970..a599127aa22eb0adfbd578f9783596e2a9f3d6c6 100644 (file)
@@ -190,7 +190,8 @@ type_call(PyTypeObject *type, PyObject *args, PyObject *kwds)
                     (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;