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 96c7c06 commit 145541cCopy full SHA for 145541c
Python/import.c
@@ -1784,9 +1784,13 @@ PyImport_Import(PyObject *module_name)
1784
Py_DECREF(r);
1785
1786
modules = PyImport_GetModuleDict();
1787
- r = PyDict_GetItem(modules, module_name);
1788
- if (r != NULL)
+ r = PyDict_GetItemWithError(modules, module_name);
+ if (r != NULL) {
1789
Py_INCREF(r);
1790
+ }
1791
+ else if (!PyErr_Occurred()) {
1792
+ PyErr_SetObject(PyExc_KeyError, module_name);
1793
1794
1795
err:
1796
Py_XDECREF(globals);
0 commit comments