Issue #27100: With statement reports missing __enter__ before __exit__. (Contributed by Jonathan Ellington.)

This commit is contained in:
Raymond Hettinger 2016-11-21 17:24:23 -08:00
parent 4e17e04237
commit a3fec1543d
3 changed files with 20 additions and 7 deletions

View file

@ -3133,15 +3133,15 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
_Py_IDENTIFIER(__exit__);
_Py_IDENTIFIER(__enter__);
PyObject *mgr = TOP();
PyObject *exit = special_lookup(mgr, &PyId___exit__), *enter;
PyObject *enter = special_lookup(mgr, &PyId___enter__), *exit;
PyObject *res;
if (enter == NULL)
goto error;
exit = special_lookup(mgr, &PyId___exit__);
if (exit == NULL)
goto error;
SET_TOP(exit);
enter = special_lookup(mgr, &PyId___enter__);
Py_DECREF(mgr);
if (enter == NULL)
goto error;
res = PyObject_CallFunctionObjArgs(enter, NULL);
Py_DECREF(enter);
if (res == NULL)