diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2018-03-23 12:34:35 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-23 12:34:35 (GMT) |
commit | 702f8f3611bc49b73772cce2b9b041bd11ff9b35 (patch) | |
tree | f712f53a42dc54831e7daf7e3686bc9c875b37b3 /Doc | |
parent | c65bf3fe4a2bde424b79e350f36b7aaa3f6476f6 (diff) | |
download | cpython-702f8f3611bc49b73772cce2b9b041bd11ff9b35.zip cpython-702f8f3611bc49b73772cce2b9b041bd11ff9b35.tar.gz cpython-702f8f3611bc49b73772cce2b9b041bd11ff9b35.tar.bz2 |
bpo-33041: Rework compiling an "async for" loop. (#6142)
* Added new opcode END_ASYNC_FOR.
* Setting global StopAsyncIteration no longer breaks "async for" loops.
* Jumping into an "async for" loop is now disabled.
* Jumping out of an "async for" loop no longer corrupts the stack.
* Simplify the compiler.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/dis.rst | 11 | ||||
-rw-r--r-- | Doc/whatsnew/3.8.rst | 4 |
2 files changed, 15 insertions, 0 deletions
diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index 47f226b..8f505e6 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -588,6 +588,17 @@ the original TOS1. .. versionadded:: 3.5 +.. opcode:: END_ASYNC_FOR + + Terminates an :keyword:`async for` loop. Handles an exception raised + when awaiting a next item. If TOS is :exc:`StopAsyncIteration` pop 7 + values from the stack and restore the exception state using the second + three of them. Otherwise re-raise the exception using the three values + from the stack. An exception handler block is removed from the block stack. + + .. versionadded:: 3.8 + + .. opcode:: BEFORE_ASYNC_WITH Resolves ``__aenter__`` and ``__aexit__`` from the object on top of the diff --git a/Doc/whatsnew/3.8.rst b/Doc/whatsnew/3.8.rst index fcc868b..4e6c851 100644 --- a/Doc/whatsnew/3.8.rst +++ b/Doc/whatsnew/3.8.rst @@ -157,3 +157,7 @@ CPython bytecode changes (Contributed by Mark Shannon, Antoine Pitrou and Serhiy Storchaka in :issue:`17611`.) + +* Added new opcode :opcode:`END_ASYNC_FOR` for handling exceptions raised + when awaiting a next item in an :keyword:`async for` loop. + (Contributed by Serhiy Storchaka in :issue:`33041`.) |