diff --git a/Python/symtable.c b/Python/symtable.c index 37e5c697405b1a..3519f62098425c 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -728,6 +728,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;