Better behavior when stepping over yield[from]. Fixes issue 16596. By Xavier de Gaye.
diff --git a/Python/ceval.c b/Python/ceval.c
index e2e882b..ab419dc 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -1904,6 +1904,9 @@
Py_DECREF(v);
if (retval == NULL) {
PyObject *val;
+ if (tstate->c_tracefunc != NULL
+ && PyErr_ExceptionMatches(PyExc_StopIteration))
+ call_exc_trace(tstate->c_tracefunc, tstate->c_traceobj, f);
err = _PyGen_FetchStopIterationValue(&val);
if (err < 0)
goto error;
@@ -2654,6 +2657,8 @@
if (PyErr_Occurred()) {
if (!PyErr_ExceptionMatches(PyExc_StopIteration))
goto error;
+ else if (tstate->c_tracefunc != NULL)
+ call_exc_trace(tstate->c_tracefunc, tstate->c_traceobj, f);
PyErr_Clear();
}
/* iterator ended normally */