py/objgenerator: Remove TODO about returning gen being called again.

The code implements correct behaviour, as tested by the new test case added
in this commit.
pull/4191/merge
Damien George 2018-09-27 15:18:24 +10:00
rodzic 6d20be31ae
commit fc1bb51af5
2 zmienionych plików z 6 dodań i 2 usunięć

Wyświetl plik

@ -128,8 +128,6 @@ mp_vm_return_kind_t mp_obj_gen_resume(mp_obj_t self_in, mp_obj_t send_value, mp_
// Explicitly mark generator as completed. If we don't do this,
// subsequent next() may re-execute statements after last yield
// again and again, leading to side effects.
// TODO: check how return with value behaves under such conditions
// in CPython.
self->code_state.ip = 0;
*ret_val = *self->code_state.sp;
break;

Wyświetl plik

@ -8,3 +8,9 @@ try:
print(next(g))
except StopIteration as e:
print(type(e), e.args)
# trying next again should raise StopIteration with no arguments
try:
print(next(g))
except StopIteration as e:
print(type(e), e.args)