aboutsummaryrefslogtreecommitdiff
path: root/py/vm.c
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2021-06-29 22:39:24 +1000
committerDamien George <damien@micropython.org>2021-07-15 00:12:41 +1000
commitb8255dd2e00f926106083de7a9b41869b226e96b (patch)
tree8da297bf82457a2527e303b45362415bcd7eb5b1 /py/vm.c
parent22fdb2130284ddea3ebe1d271d05d670546e788f (diff)
py/vm: Simplify handling of MP_OBJ_STOP_ITERATION in yield-from opcode.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'py/vm.c')
-rw-r--r--py/vm.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/py/vm.c b/py/vm.c
index 5365014fc..bbfc9914e 100644
--- a/py/vm.c
+++ b/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);