We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e45ea37 commit fab05deCopy full SHA for fab05de
Python/import.c
@@ -1785,9 +1785,13 @@ PyImport_Import(PyObject *module_name)
1785
Py_DECREF(r);
1786
1787
modules = PyImport_GetModuleDict();
1788
- r = PyDict_GetItem(modules, module_name);
1789
- if (r != NULL)
+ r = PyDict_GetItemWithError(modules, module_name);
+ if (r != NULL) {
1790
Py_INCREF(r);
1791
+ }
1792
+ else if (!PyErr_Occurred()) {
1793
+ PyErr_SetObject(PyExc_KeyError, module_name);
1794
1795
1796
err:
1797
Py_XDECREF(globals);
0 commit comments