mirror of
https://github.com/python/cpython.git
synced 2025-11-25 21:11:09 +00:00
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(). Will fix this in 2.2.1 too.
This commit is contained in:
parent
a2a206b917
commit
9fc8a29663
2 changed files with 22 additions and 0 deletions
|
|
@ -3019,7 +3019,23 @@ def string_exceptions():
|
||||||
except:
|
except:
|
||||||
raise TestFailed, "string subclass allowed as exception"
|
raise TestFailed, "string subclass allowed as exception"
|
||||||
|
|
||||||
|
def do_this_first():
|
||||||
|
if verbose:
|
||||||
|
print "Testing SF bug 551412 ..."
|
||||||
|
# This dumps core when SF bug 551412 isn't fixed --
|
||||||
|
# but only when test_descr.py is run separately.
|
||||||
|
# (That can't be helped -- as soon as PyType_Ready()
|
||||||
|
# is called for PyLong_Type, the bug is gone.)
|
||||||
|
class UserLong(object):
|
||||||
|
def __pow__(self, *args):
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
pow(0L, UserLong(), 0L)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
def test_main():
|
def test_main():
|
||||||
|
do_this_first()
|
||||||
class_docstrings()
|
class_docstrings()
|
||||||
lists()
|
lists()
|
||||||
dicts()
|
dicts()
|
||||||
|
|
|
||||||
|
|
@ -1221,6 +1221,12 @@ _PyType_Lookup(PyTypeObject *type, PyObject *name)
|
||||||
|
|
||||||
/* Look in tp_dict of types in MRO */
|
/* Look in tp_dict of types in MRO */
|
||||||
mro = type->tp_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));
|
assert(PyTuple_Check(mro));
|
||||||
n = PyTuple_GET_SIZE(mro);
|
n = PyTuple_GET_SIZE(mro);
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue