From: Serhiy Storchaka Date: Wed, 10 Feb 2016 08:31:20 +0000 (+0200) Subject: Issue #25698: Prevent possible replacing imported module with the empty one X-Git-Tag: v3.6.0a1~622^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=48a583b1d83d9c44c9dd9facb9331737518d6618;p=thirdparty%2FPython%2Fcpython.git Issue #25698: Prevent possible replacing imported module with the empty one if the stack is too deep. --- diff --git a/Python/import.c b/Python/import.c index edf030d87ae9..0b843dafd3df 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;