From 6d36fd8401bcdc46a082c4920782942e2374ee0b Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Fri, 24 May 2002 21:41:26 +0000 Subject: [PATCH] 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. --- Objects/typeobject.c | 6 ++++++ 1 file changed, 6 insertions(+) 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++) { -- 2.47.3