Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6351757

Browse files
committed
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.
1 parent a0b9075 commit 6351757

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ Oscar Nierstrasz
336336
Hrvoje Niksic
337337
Bill Noon
338338
Stefan Norberg
339+
Tim Northover
339340
Joe Norton
340341
Neal Norwitz
341342
Jeffrey Ollie

Objects/typeobject.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,11 @@ mro_implementation(PyTypeObject *type)
742742
int i, n, ok;
743743
PyObject *bases, *result;
744744

745+
if(type->tp_dict == NULL) {
746+
if(PyType_Ready(type) < 0)
747+
return NULL;
748+
}
749+
745750
bases = type->tp_bases;
746751
n = PyTuple_GET_SIZE(bases);
747752
result = Py_BuildValue("[O]", (PyObject *)type);

0 commit comments

Comments
 (0)