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.
This commit is contained in:
parent
6d20be31ae
commit
fc1bb51af5
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue