py/vm: Simplify handling of MP_OBJ_STOP_ITERATION in yield-from opcode.
Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
13
py/vm.c
13
py/vm.c
@@ -1257,16 +1257,9 @@ yield:
|
||||
PUSH(ret_value);
|
||||
goto yield;
|
||||
} else if (ret_kind == MP_VM_RETURN_NORMAL) {
|
||||
// Pop exhausted gen
|
||||
sp--;
|
||||
if (ret_value == MP_OBJ_STOP_ITERATION) {
|
||||
// Optimize StopIteration
|
||||
// TODO: get StopIteration's value
|
||||
PUSH(mp_const_none);
|
||||
} else {
|
||||
PUSH(ret_value);
|
||||
}
|
||||
|
||||
// The generator has finished, and returned a value via StopIteration
|
||||
// Replace exhausted generator with the returned value
|
||||
SET_TOP(ret_value);
|
||||
// If we injected GeneratorExit downstream, then even
|
||||
// if it was swallowed, we re-raise GeneratorExit
|
||||
GENERATOR_EXIT_IF_NEEDED(t_exc);
|
||||
|
||||
Reference in New Issue
Block a user