Fix weird yield from interpreter bug

This commit is contained in:
coolreader18
2019-08-07 13:50:55 -05:00
parent d7936f1ee6
commit ed3b1973be
2 changed files with 7 additions and 7 deletions

View File

@@ -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

View File

@@ -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<PyObjectRef> {