mirror of
https://github.com/python/cpython.git
synced 2025-10-06 15:11:58 +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
|
@ -2887,12 +2887,11 @@ PyImport_ImportModuleLevelObject(PyObject *name, PyObject *globals,
|
|||
}
|
||||
}
|
||||
else {
|
||||
PyObject *path;
|
||||
if (PyObject_GetOptionalAttr(mod, &_Py_ID(__path__), &path) < 0) {
|
||||
int has_path = PyObject_HasAttrWithError(mod, &_Py_ID(__path__));
|
||||
if (has_path < 0) {
|
||||
goto error;
|
||||
}
|
||||
if (path) {
|
||||
Py_DECREF(path);
|
||||
if (has_path) {
|
||||
final_mod = PyObject_CallMethodObjArgs(
|
||||
IMPORTLIB(interp), &_Py_ID(_handle_fromlist),
|
||||
mod, fromlist, IMPORT_FUNC(interp), NULL);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue