diff --git a/tests/snippets/generators.py b/tests/snippets/generators.py index 3b7dc77c3..0aa1726a2 100644 --- a/tests/snippets/generators.py +++ b/tests/snippets/generators.py @@ -32,10 +32,11 @@ def g3(): yield 23 yield from make_numbers() yield 44 + yield from make_numbers() r = list(g3()) # print(r) -assert r == [23, 1, 2, 3, 44] +assert r == [23, 1, 2, 3, 44, 1, 2, 3] def g4(): yield diff --git a/vm/src/frame.rs b/vm/src/frame.rs index b9ba09905..71f48f3eb 100644 --- a/vm/src/frame.rs +++ b/vm/src/frame.rs @@ -372,11 +372,7 @@ impl Frame { *self.lasti.borrow_mut() -= 1; Ok(Some(ExecutionResult::Yield(value))) } - None => { - // Pop iterator from stack: - self.pop_value(); - Ok(None) - } + None => Ok(None), } } bytecode::Instruction::SetupLoop { start, end } => { @@ -1173,7 +1169,10 @@ impl Frame { } fn pop_value(&self) -> PyObjectRef { - self.stack.borrow_mut().pop().unwrap() + self.stack + .borrow_mut() + .pop() + .expect("Tried to pop value but there was nothing on the stack") } fn pop_multiple(&self, count: usize) -> Vec {