From: Guido van Rossum Date: Tue, 18 Jun 2002 16:44:57 +0000 (+0000) Subject: Patch from SF bug 570483 (Tim Northover). X-Git-Tag: v2.3c1~5281 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=63517577fdcd7c17072e1a612f6d91a35030d571;p=python 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. --- diff --git a/Misc/ACKS b/Misc/ACKS index c7da1b0354..fb64941312 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -336,6 +336,7 @@ Oscar Nierstrasz Hrvoje Niksic Bill Noon Stefan Norberg +Tim Northover Joe Norton Neal Norwitz Jeffrey Ollie diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 0051179c2f..7918af09db 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -742,6 +742,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);