Commit 48a583b1 authored by Serhiy Storchaka's avatar Serhiy Storchaka

Issue #25698: Prevent possible replacing imported module with the empty one

if the stack is too deep.
parent c04fb56e
......@@ -671,9 +671,13 @@ PyImport_AddModuleObject(PyObject *name)
PyObject *modules = PyImport_GetModuleDict();
PyObject *m;
if ((m = PyDict_GetItem(modules, name)) != NULL &&
PyModule_Check(m))
if ((m = PyDict_GetItemWithError(modules, name)) != NULL &&
PyModule_Check(m)) {
return m;
}
if (PyErr_Occurred()) {
return NULL;
}
m = PyModule_NewObject(name);
if (m == NULL)
return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment