Skip to content

Fix async block mismatch #5275

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions vm/src/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,9 @@ impl ExecutingFrame<'_> {
}
bytecode::Instruction::EndAsyncFor => {
let exc = self.pop_value();
self.pop_value(); // async iterator we were calling __anext__ on
let except_block = self.pop_block(); // pushed by TryExcept unwind
debug_assert_eq!(except_block.level, self.state.stack.len());
let _async_iterator = self.pop_value(); // __anext__ provider in the loop
if exc.fast_isinstance(vm.ctx.exceptions.stop_async_iteration) {
vm.take_exception().expect("Should have exception in stack");
Ok(None)
Expand Down Expand Up @@ -1496,8 +1498,7 @@ impl ExecutingFrame<'_> {
}
PyIterReturn::StopIteration(value) => {
let value = vm.unwrap_or_none(value);
self.pop_value();
self.push_value(value);
self.replace_top(value);
Ok(None)
}
}
Expand Down Expand Up @@ -1933,6 +1934,7 @@ impl ExecutingFrame<'_> {
}

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