]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Backport:
authorGuido van Rossum <guido@python.org>
Tue, 18 Jun 2002 16:46:57 +0000 (16:46 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 18 Jun 2002 16:46:57 +0000 (16:46 +0000)
Patch from SF bug 570483 (Tim Northover).

In a fresh interpreter, type.mro(tuple) would segfault, because
PyType_Ready() isn't called for tuple yet.  To fix, call
PyType_Ready(type) if type->tp_dict is NULL.

Objects/typeobject.c

index ca5140c17fa33b0a3067b5ea671916fec6318e22..09e4aa7e945cf9f3497ff5b4f09b2347c1b664bb 100644 (file)
@@ -733,6 +733,11 @@ mro_implementation(PyTypeObject *type)
        int i, n, ok;
        PyObject *bases, *result;
 
+       if(type->tp_dict == NULL) {
+               if(PyType_Ready(type) < 0)
+                       return NULL;
+       }
+
        bases = type->tp_bases;
        n = PyTuple_GET_SIZE(bases);
        result = Py_BuildValue("[O]", (PyObject *)type);