diff options
author | Yury Selivanov <yury@magic.io> | 2018-06-08 00:31:26 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-08 00:31:26 (GMT) |
commit | 52698c7ad9eae9feb35839fde17a7d1da8036a9b (patch) | |
tree | 1db0d329f430f5eda34575454d35b0b7e5570249 /Objects/genobject.c | |
parent | 378c53cc3187dba57c7560ccc2557f516c8a7bc8 (diff) | |
download | cpython-52698c7ad9eae9feb35839fde17a7d1da8036a9b.zip cpython-52698c7ad9eae9feb35839fde17a7d1da8036a9b.tar.gz cpython-52698c7ad9eae9feb35839fde17a7d1da8036a9b.tar.bz2 |
bpo-33786: Fix asynchronous generators to handle GeneratorExit in athrow() (GH-7467)
Diffstat (limited to 'Objects/genobject.c')
-rw-r--r-- | Objects/genobject.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/Objects/genobject.c b/Objects/genobject.c index 9f59338..e55cfd2 100644 --- a/Objects/genobject.c +++ b/Objects/genobject.c @@ -1876,21 +1876,20 @@ yield_close: return NULL; check_error: - if (PyErr_ExceptionMatches(PyExc_StopAsyncIteration)) { + if (PyErr_ExceptionMatches(PyExc_StopAsyncIteration) || + PyErr_ExceptionMatches(PyExc_GeneratorExit)) + { o->agt_state = AWAITABLE_STATE_CLOSED; if (o->agt_args == NULL) { /* when aclose() is called we don't want to propagate - StopAsyncIteration; just raise StopIteration, signalling - that 'aclose()' is done. */ + StopAsyncIteration or GeneratorExit; just raise + StopIteration, signalling that this 'aclose()' await + is done. + */ PyErr_Clear(); PyErr_SetNone(PyExc_StopIteration); } } - else if (PyErr_ExceptionMatches(PyExc_GeneratorExit)) { - o->agt_state = AWAITABLE_STATE_CLOSED; - PyErr_Clear(); /* ignore these errors */ - PyErr_SetNone(PyExc_StopIteration); - } return NULL; } |