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 fb0825c commit 263dcc3Copy full SHA for 263dcc3
Python/import.c
@@ -1806,9 +1806,13 @@ PyImport_Import(PyObject *module_name)
1806
Py_DECREF(r);
1807
1808
modules = PyImport_GetModuleDict();
1809
- r = PyDict_GetItem(modules, module_name);
1810
- if (r != NULL)
+ r = PyDict_GetItemWithError(modules, module_name);
+ if (r != NULL) {
1811
Py_INCREF(r);
1812
+ }
1813
+ else if (!PyErr_Occurred()) {
1814
+ PyErr_SetObject(PyExc_KeyError, module_name);
1815
1816
1817
err:
1818
Py_XDECREF(globals);
0 commit comments