projects
/
python
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
96c7c06
)
bpo-30626: Fix error handling in PyImport_Import(). (#2103)
author
Serhiy Storchaka
<storchaka@gmail.com>
Thu, 15 Jun 2017 17:54:38 +0000
(20:54 +0300)
committer
GitHub
<noreply@github.com>
Thu, 15 Jun 2017 17:54:38 +0000
(20:54 +0300)
In rare circumstances PyImport_Import() could return NULL without raising
an error.
Python/import.c
patch
|
blob
|
history
diff --git
a/Python/import.c
b/Python/import.c
index 9a78d6adc7a2af85b416ff04144b85e8c9e7db5c..d8a207b4b369afc564a0c6277fe570608d7783da 100644
(file)
--- a/
Python/import.c
+++ b/
Python/import.c
@@
-1784,9
+1784,13
@@
PyImport_Import(PyObject *module_name)
Py_DECREF(r);
modules = PyImport_GetModuleDict();
- r = PyDict_GetItem(modules, module_name);
- if (r != NULL)
+ r = PyDict_GetItem
WithError
(modules, module_name);
+ if (r != NULL)
{
Py_INCREF(r);
+ }
+ else if (!PyErr_Occurred()) {
+ PyErr_SetObject(PyExc_KeyError, module_name);
+ }
err:
Py_XDECREF(globals);