mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
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
This commit is contained in:
parent
e5527f2cdd
commit
89df62c120
17 changed files with 235 additions and 154 deletions
|
@ -3109,6 +3109,14 @@ branchesiter_next(branchesiterator *bi)
|
|||
int not_taken = next_offset + 1;
|
||||
bi->bi_offset = not_taken;
|
||||
return int_triple(offset*2, not_taken*2, (next_offset + oparg)*2);
|
||||
case END_ASYNC_FOR:
|
||||
oparg = (oparg << 8) | inst.op.arg;
|
||||
int src_offset = next_offset - oparg;
|
||||
bi->bi_offset = next_offset;
|
||||
assert(_Py_GetBaseCodeUnit(bi->bi_code, src_offset).op.code == END_SEND);
|
||||
assert(_Py_GetBaseCodeUnit(bi->bi_code, src_offset+1).op.code == NOT_TAKEN);
|
||||
not_taken = src_offset + 2;
|
||||
return int_triple(src_offset *2, not_taken*2, next_offset*2);
|
||||
default:
|
||||
oparg = 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue