bpo-28893: Set __cause__ for errors in async iteration protocol (#407)

This commit is contained in:
Yury Selivanov 2017-03-02 22:20:00 -05:00 committed by GitHub
parent 8d26aa930c
commit 398ff91ac0
3 changed files with 44 additions and 3 deletions

View file

@ -1855,13 +1855,13 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
awaitable = _PyCoro_GetAwaitableIter(iter);
if (awaitable == NULL) {
SET_TOP(NULL);
PyErr_Format(
_PyErr_FormatFromCause(
PyExc_TypeError,
"'async for' received an invalid object "
"from __aiter__: %.100s",
Py_TYPE(iter)->tp_name);
SET_TOP(NULL);
Py_DECREF(iter);
goto error;
} else {
@ -1920,7 +1920,7 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
awaitable = _PyCoro_GetAwaitableIter(next_iter);
if (awaitable == NULL) {
PyErr_Format(
_PyErr_FormatFromCause(
PyExc_TypeError,
"'async for' received an invalid object "
"from __anext__: %.100s",