]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #25698: Prevent possible replacing imported module with the empty one
authorSerhiy Storchaka <storchaka@gmail.com>
Wed, 10 Feb 2016 08:31:20 +0000 (10:31 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Wed, 10 Feb 2016 08:31:20 +0000 (10:31 +0200)
if the stack is too deep.

Python/import.c

index edf030d87ae9d359947a767c15aa0ed265525a39..0b843dafd3df21d2d04877e77d0b9de0025931b3 100644 (file)
@@ -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;