diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-11-06 16:47:03 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-11-06 16:47:03 (GMT) |
commit | 60e49aa7560ca70bc5de461abc68eb72d8739e17 (patch) | |
tree | cecbf64f1c2c52048c04d337132af485aeffd87a /Modules | |
parent | f66f03bd358c3c481292f2624b8c947f4f77c370 (diff) | |
parent | 24411f8a8daace4ebf8abd41091b681160b4fb89 (diff) | |
download | cpython-60e49aa7560ca70bc5de461abc68eb72d8739e17.zip cpython-60e49aa7560ca70bc5de461abc68eb72d8739e17.tar.gz cpython-60e49aa7560ca70bc5de461abc68eb72d8739e17.tar.bz2 |
Issue #23996: Added _PyGen_SetStopIterationValue for safe raising
StopIteration with value. More safely handle non-normalized exceptions
in -_PyGen_FetchStopIterationValue.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_asynciomodule.c | 22 |
1 files changed, 4 insertions, 18 deletions
diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c index 18dd37b..7df6fa5 100644 --- a/Modules/_asynciomodule.c +++ b/Modules/_asynciomodule.c @@ -997,26 +997,12 @@ FutureIter_iternext(futureiterobject *it) res = _asyncio_Future_result_impl(fut); if (res != NULL) { - /* The result of the Future is not an exception. - - We construct an exception instance manually with - PyObject_CallFunctionObjArgs and pass it to PyErr_SetObject - (similarly to what genobject.c does). - - We do this to handle a situation when "res" is a tuple, in which - case PyErr_SetObject would set the value of StopIteration to - the first element of the tuple. - - (See PyErr_SetObject/_PyErr_CreateException code for details.) - */ - PyObject *e = PyObject_CallFunctionObjArgs( - PyExc_StopIteration, res, NULL); - Py_DECREF(res); - if (e == NULL) { + /* The result of the Future is not an exception. */ + if (_PyGen_SetStopIterationValue(res) < 0) { + Py_DECREF(res); return NULL; } - PyErr_SetObject(PyExc_StopIteration, e); - Py_DECREF(e); + Py_DECREF(res); } it->future = NULL; |