mirror of
https://github.com/python/cpython.git
synced 2025-07-09 20:35:26 +00:00
bpo-36370: Check for PyErr_Occurred() after PyImport_GetModule() (GH-12504)
This commit is contained in:
parent
d1e768a677
commit
027b09c5a1
4 changed files with 24 additions and 11 deletions
|
@ -4948,7 +4948,7 @@ import_from(PyObject *v, PyObject *name)
|
|||
}
|
||||
x = PyImport_GetModule(fullmodname);
|
||||
Py_DECREF(fullmodname);
|
||||
if (x == NULL) {
|
||||
if (x == NULL && !PyErr_Occurred()) {
|
||||
goto error;
|
||||
}
|
||||
Py_DECREF(pkgname);
|
||||
|
@ -4971,7 +4971,7 @@ import_from(PyObject *v, PyObject *name)
|
|||
"cannot import name %R from %R (unknown location)",
|
||||
name, pkgname_or_unknown
|
||||
);
|
||||
/* NULL check for errmsg done by PyErr_SetImportError. */
|
||||
/* NULL checks for errmsg and pkgname done by PyErr_SetImportError. */
|
||||
PyErr_SetImportError(errmsg, pkgname, NULL);
|
||||
}
|
||||
else {
|
||||
|
@ -4979,7 +4979,7 @@ import_from(PyObject *v, PyObject *name)
|
|||
"cannot import name %R from %R (%S)",
|
||||
name, pkgname_or_unknown, pkgpath
|
||||
);
|
||||
/* NULL check for errmsg done by PyErr_SetImportError. */
|
||||
/* NULL checks for errmsg and pkgname done by PyErr_SetImportError. */
|
||||
PyErr_SetImportError(errmsg, pkgname, pkgpath);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue