diff --git a/Python/ceval.c b/Python/ceval.c index ebf073a87fb..83296f637fc 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -3138,8 +3138,10 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag) if (enter == NULL) goto error; exit = special_lookup(mgr, &PyId___exit__); - if (exit == NULL) + if (exit == NULL) { + Py_DECREF(enter); goto error; + } SET_TOP(exit); Py_DECREF(mgr); res = PyObject_CallFunctionObjArgs(enter, NULL);