summaryrefslogtreecommitdiff
path: root/Objects/funcobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/funcobject.c')
-rw-r--r--Objects/funcobject.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/Objects/funcobject.c b/Objects/funcobject.c
index 4fab35833d..e8e2d2e15c 100644
--- a/Objects/funcobject.c
+++ b/Objects/funcobject.c
@@ -54,11 +54,15 @@ PyFunction_NewWithQualName(PyObject *code, PyObject *globals, PyObject *qualname
/* __module__: If module name is in globals, use it.
Otherwise, use None. */
- module = PyDict_GetItem(globals, __name__);
+ module = PyDict_GetItemWithError(globals, __name__);
if (module) {
Py_INCREF(module);
op->func_module = module;
}
+ else if (PyErr_Occurred()) {
+ Py_DECREF(op);
+ return NULL;
+ }
if (qualname)
op->func_qualname = qualname;
else