diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2020-01-20 23:06:40 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-20 23:06:40 (GMT) |
commit | 5cadd3fe3aead1b5bee1438dc03383d6739d4209 (patch) | |
tree | f43a6fad9c24094f3432b275ebc2bd57c4cb882b /Objects | |
parent | 6aeed01901d020363e383821b38614816d0b4032 (diff) | |
download | cpython-5cadd3fe3aead1b5bee1438dc03383d6739d4209.zip cpython-5cadd3fe3aead1b5bee1438dc03383d6739d4209.tar.gz cpython-5cadd3fe3aead1b5bee1438dc03383d6739d4209.tar.bz2 |
bpo-39386: Prevent double awaiting of async iterator (GH-18081)
(cherry picked from commit a96e06db77dcbd3433d39761ddb4615d7d96284a)
Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/genobject.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/Objects/genobject.c b/Objects/genobject.c index 5643553..72aa872 100644 --- a/Objects/genobject.c +++ b/Objects/genobject.c @@ -1533,7 +1533,9 @@ async_gen_asend_send(PyAsyncGenASend *o, PyObject *arg) PyObject *result; if (o->ags_state == AWAITABLE_STATE_CLOSED) { - PyErr_SetNone(PyExc_StopIteration); + PyErr_SetString( + PyExc_RuntimeError, + "cannot reuse already awaited __anext__()/asend()"); return NULL; } @@ -1576,7 +1578,9 @@ async_gen_asend_throw(PyAsyncGenASend *o, PyObject *args) PyObject *result; if (o->ags_state == AWAITABLE_STATE_CLOSED) { - PyErr_SetNone(PyExc_StopIteration); + PyErr_SetString( + PyExc_RuntimeError, + "cannot reuse already awaited __anext__()/asend()"); return NULL; } @@ -1810,7 +1814,9 @@ async_gen_athrow_send(PyAsyncGenAThrow *o, PyObject *arg) if (f == NULL || f->f_stacktop == NULL || o->agt_state == AWAITABLE_STATE_CLOSED) { - PyErr_SetNone(PyExc_StopIteration); + PyErr_SetString( + PyExc_RuntimeError, + "cannot reuse already awaited aclose()/athrow()"); return NULL; } @@ -1932,7 +1938,9 @@ async_gen_athrow_throw(PyAsyncGenAThrow *o, PyObject *args) PyObject *retval; if (o->agt_state == AWAITABLE_STATE_CLOSED) { - PyErr_SetNone(PyExc_StopIteration); + PyErr_SetString( + PyExc_RuntimeError, + "cannot reuse already awaited aclose()/athrow()"); return NULL; } |