From: Guido van Rossum Date: Fri, 24 May 2002 21:41:26 +0000 (+0000) Subject: Fix for SF bug 551412. When _PyType_Lookup() is called on a type X-Git-Tag: v2.2.2b1~357 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6d36fd8401bcdc46a082c4920782942e2374ee0b;p=thirdparty%2FPython%2Fcpython.git Fix for SF bug 551412. When _PyType_Lookup() is called on a type whose tp_mro hasn't been initialized, it would dump core. Fix this by checking for NULL and calling PyType_Ready(). Backport from 2.3. --- diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 74dfff94e8ff..f5a1a01a49af 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -1218,6 +1218,12 @@ _PyType_Lookup(PyTypeObject *type, PyObject *name) /* Look in tp_dict of types in MRO */ mro = type->tp_mro; + if (mro == NULL) { + if (PyType_Ready(type) < 0) + return NULL; + mro = type->tp_mro; + assert(mro != NULL); + } assert(PyTuple_Check(mro)); n = PyTuple_GET_SIZE(mro); for (i = 0; i < n; i++) {