mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
bpo-39386: Prevent double awaiting of async iterator (GH-18081)
This commit is contained in:
parent
2c49becc69
commit
a96e06db77
3 changed files with 49 additions and 4 deletions
|
@ -1518,7 +1518,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;
|
||||
}
|
||||
|
||||
|
@ -1561,7 +1563,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;
|
||||
}
|
||||
|
||||
|
@ -1795,7 +1799,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;
|
||||
}
|
||||
|
||||
|
@ -1917,7 +1923,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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue