diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-02-10 08:31:20 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-02-10 08:31:20 (GMT) |
commit | 48a583b1d83d9c44c9dd9facb9331737518d6618 (patch) | |
tree | a9bf8edac7c1daa4bc1aac074f403ccbb2b22b49 | |
parent | c04fb56e36999a4162e6ccfe1f9357100abaee99 (diff) | |
download | cpython-48a583b1d83d9c44c9dd9facb9331737518d6618.zip cpython-48a583b1d83d9c44c9dd9facb9331737518d6618.tar.gz cpython-48a583b1d83d9c44c9dd9facb9331737518d6618.tar.bz2 |
Issue #25698: Prevent possible replacing imported module with the empty one
if the stack is too deep.
-rw-r--r-- | Python/import.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Python/import.c b/Python/import.c index edf030d..0b843da 100644 --- a/Python/import.c +++ b/Python/import.c @@ -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; |