Issue #26906: Resolving special methods of uninitialized type now causes
implicit initialization of the type instead of a fail.
This commit is contained in:
parent
1c1130fb5f
commit
8ef34600c7
|
@ -10,6 +10,9 @@ Release date: TBA
|
||||||
Core and Builtins
|
Core and Builtins
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- Issue #26906: Resolving special methods of uninitialized type now causes
|
||||||
|
implicit initialization of the type instead of a fail.
|
||||||
|
|
||||||
- Issue #18287: PyType_Ready() now checks that tp_name is not NULL.
|
- Issue #18287: PyType_Ready() now checks that tp_name is not NULL.
|
||||||
Original patch by Niklas Koep.
|
Original patch by Niklas Koep.
|
||||||
|
|
||||||
|
|
|
@ -2869,11 +2869,25 @@ _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 is NULL, the type is either not yet initialized
|
if (mro == NULL) {
|
||||||
by PyType_Ready(), or already cleared by type_clear().
|
if ((type->tp_flags & Py_TPFLAGS_READYING) == 0 &&
|
||||||
Either way the safest thing to do is to return NULL. */
|
PyType_Ready(type) < 0) {
|
||||||
if (mro == NULL)
|
/* It's not ideal to clear the error condition,
|
||||||
|
but this function is documented as not setting
|
||||||
|
an exception, and I don't want to change that.
|
||||||
|
When PyType_Ready() can't proceed, it won't
|
||||||
|
set the "ready" flag, so future attempts to ready
|
||||||
|
the same type will call it again -- hopefully
|
||||||
|
in a context that propagates the exception out.
|
||||||
|
*/
|
||||||
|
PyErr_Clear();
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
mro = type->tp_mro;
|
||||||
|
if (mro == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
res = NULL;
|
res = NULL;
|
||||||
/* keep a strong reference to mro because type->tp_mro can be replaced
|
/* keep a strong reference to mro because type->tp_mro can be replaced
|
||||||
|
|
Loading…
Reference in New Issue