diff --git a/Python/symtable.c b/Python/symtable.c index 52d5932896b263..83137b491f282c 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -977,6 +977,12 @@ update_symbols(PyObject *symbols, PyObject *scopes, } Py_DECREF(name); } + + /* Check if loop ended because of exception in PyIter_Next */ + if (PyErr_Occurred()) { + goto error; + } + Py_DECREF(itr); Py_DECREF(v_free); return 1;