diff options
| author | Yury Selivanov <yury@magic.io> | 2016-10-20 19:54:51 (GMT) |
|---|---|---|
| committer | Yury Selivanov <yury@magic.io> | 2016-10-20 19:54:51 (GMT) |
| commit | 3ceee7b0dad2c262bf6eaadb473b51daa82d9025 (patch) | |
| tree | 34b15f7e0d7ccfae55de9323139a5d536768981a /Modules/_asynciomodule.c | |
| parent | ae8ca1c0e2878d1c0ea5b19ca25ca0ac77e1e942 (diff) | |
| parent | a4b884f9009e9797e8bb7f8c9e797b4f033dd37e (diff) | |
| download | cpython-3ceee7b0dad2c262bf6eaadb473b51daa82d9025.zip cpython-3ceee7b0dad2c262bf6eaadb473b51daa82d9025.tar.gz cpython-3ceee7b0dad2c262bf6eaadb473b51daa82d9025.tar.bz2 | |
Merge 3.6 (issue #28492)
Diffstat (limited to 'Modules/_asynciomodule.c')
| -rw-r--r-- | Modules/_asynciomodule.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c index d1d9c54..d9fe63d 100644 --- a/Modules/_asynciomodule.c +++ b/Modules/_asynciomodule.c @@ -787,9 +787,26 @@ FutureIter_iternext(futureiterobject *it) res = FutureObj_result(fut, NULL); if (res != NULL) { - // normal result - PyErr_SetObject(PyExc_StopIteration, res); + /* The result of the Future is not an exception. + + We cunstruct an exception instance manually with + PyObject_CallFunctionObjArgs and pass it to PyErr_SetObject + (similarly to what genobject.c does). + + This is 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) { + return NULL; + } + PyErr_SetObject(PyExc_StopIteration, e); + Py_DECREF(e); } it->future = NULL; |
