Skip to content

Commit

Permalink
The object returned by tp_new() may not have a tp_init.
Browse files Browse the repository at this point in the history
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().
  • Loading branch information
jeremyhylton committed Jul 16, 2002
1 parent 012b69c commit 719841e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 719841e

Please sign in to comment.