summaryrefslogtreecommitdiff
path: root/py/vm.c
diff options
context:
space:
mode:
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);