]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix for SF bug 551412. When _PyType_Lookup() is called on a type
authorGuido van Rossum <guido@python.org>
Fri, 24 May 2002 21:41:26 +0000 (21:41 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 24 May 2002 21:41:26 +0000 (21:41 +0000)
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

index 74dfff94e8ffe98c51a12727b0f17f8c1d9593d0..f5a1a01a49af6b6cd106c710d319e530b6611764 100644 (file)
@@ -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++) {