diff options
author | Mark Shannon <mark@hotpy.org> | 2025-03-07 14:30:31 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-07 14:30:31 +0000 |
commit | 89df62c12093bfa079860a93032468ebece3774d (patch) | |
tree | e982ec3b0a29f1c8fb727e0fe4b49b62909b5fb0 /Lib/dis.py | |
parent | e5527f2cdda501542bf94179093e1a15d7889b74 (diff) | |
download | cpython-89df62c12093bfa079860a93032468ebece3774d.tar.gz cpython-89df62c12093bfa079860a93032468ebece3774d.zip |
GH-128534: Fix behavior of branch monitoring for `async for` (GH-130847)
* Both branches in a pair now have a common source and are included in co_branches
Diffstat (limited to 'Lib/dis.py')
-rw-r--r-- | Lib/dis.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Lib/dis.py b/Lib/dis.py index 72cc2d19456..c0a25dea2a9 100644 --- a/Lib/dis.py +++ b/Lib/dis.py @@ -52,6 +52,7 @@ STORE_FAST_LOAD_FAST = opmap['STORE_FAST_LOAD_FAST'] STORE_FAST_STORE_FAST = opmap['STORE_FAST_STORE_FAST'] IS_OP = opmap['IS_OP'] CONTAINS_OP = opmap['CONTAINS_OP'] +END_ASYNC_FOR = opmap['END_ASYNC_FOR'] CACHE = opmap["CACHE"] @@ -605,7 +606,8 @@ class ArgResolver: argval = self.offset_from_jump_arg(op, arg, offset) lbl = self.get_label_for_offset(argval) assert lbl is not None - argrepr = f"to L{lbl}" + preposition = "from" if deop == END_ASYNC_FOR else "to" + argrepr = f"{preposition} L{lbl}" elif deop in (LOAD_FAST_LOAD_FAST, STORE_FAST_LOAD_FAST, STORE_FAST_STORE_FAST): arg1 = arg >> 4 arg2 = arg & 15 @@ -745,7 +747,8 @@ def _parse_exception_table(code): def _is_backward_jump(op): return opname[op] in ('JUMP_BACKWARD', - 'JUMP_BACKWARD_NO_INTERRUPT') + 'JUMP_BACKWARD_NO_INTERRUPT', + 'END_ASYNC_FOR') # Not really a jump, but it has a "target" def _get_instructions_bytes(code, linestarts=None, line_offset=0, co_positions=None, original_code=None, arg_resolver=None): |