mirror of
https://github.com/python/cpython.git
synced 2025-10-09 08:31:26 +00:00
gh-108511: Add C API functions which do not silently ignore errors (GH-109025)
Add the following functions: * PyObject_HasAttrWithError() * PyObject_HasAttrStringWithError() * PyMapping_HasKeyWithError() * PyMapping_HasKeyStringWithError()
This commit is contained in:
parent
e57ecf6bbc
commit
add16f1a5e
28 changed files with 330 additions and 111 deletions
|
@ -3879,16 +3879,14 @@ type_new_get_bases(type_new_ctx *ctx, PyObject **type)
|
|||
if (PyType_Check(base)) {
|
||||
continue;
|
||||
}
|
||||
PyObject *mro_entries;
|
||||
if (PyObject_GetOptionalAttr(base, &_Py_ID(__mro_entries__),
|
||||
&mro_entries) < 0) {
|
||||
int rc = PyObject_HasAttrWithError(base, &_Py_ID(__mro_entries__));
|
||||
if (rc < 0) {
|
||||
return -1;
|
||||
}
|
||||
if (mro_entries != NULL) {
|
||||
if (rc) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"type() doesn't support MRO entry resolution; "
|
||||
"use types.new_class()");
|
||||
Py_DECREF(mro_entries);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue