Skip to content

Commit acd9ea5

Browse files
committed
Fix async for block
1 parent 794a2a1 commit acd9ea5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

vm/src/frame.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,9 @@ impl ExecutingFrame<'_> {
10051005
}
10061006
bytecode::Instruction::EndAsyncFor => {
10071007
let exc = self.pop_value();
1008-
self.pop_value(); // async iterator we were calling __anext__ on
1008+
let except_block = self.pop_block(); // pushed by TryExcept unwind
1009+
debug_assert_eq!(except_block.level, self.state.stack.len());
1010+
let _async_iterator = self.pop_value(); // __anext__ provider in the loop
10091011
if exc.fast_isinstance(vm.ctx.exceptions.stop_async_iteration) {
10101012
vm.take_exception().expect("Should have exception in stack");
10111013
Ok(None)
@@ -1932,6 +1934,7 @@ impl ExecutingFrame<'_> {
19321934
}
19331935

19341936
#[inline]
1937+
#[track_caller] // not a real track_caller but push_value is not very useful
19351938
fn push_value(&mut self, obj: PyObjectRef) {
19361939
match self.state.stack.try_push(obj) {
19371940
Ok(()) => {}

0 commit comments

Comments
 (0)