Skip to content
Snippets Groups Projects
Commit d5e629ad authored by Paul Sokolovsky's avatar Paul Sokolovsky Committed by Damien George
Browse files

objgenerator: Can optimize StopIteration to STOP_ITERATION only if arg is None.

Unfortunately, MP_OBJ_STOP_ITERATION doesn't have means to pass an associated
value, so we can't optimize StopIteration exception with (non-None) argument
to MP_OBJ_STOP_ITERATION.
parent aa9dbb1b
No related branches found
No related tags found
No related merge requests found
......@@ -171,10 +171,12 @@ STATIC mp_obj_t gen_resume_and_raise(mp_obj_t self_in, mp_obj_t send_value, mp_o
// of mp_iternext() protocol, but this function is called by other methods
// too, which may not handled MP_OBJ_STOP_ITERATION.
if (mp_obj_is_subclass_fast(mp_obj_get_type(ret), &mp_type_StopIteration)) {
return MP_OBJ_STOP_ITERATION;
} else {
nlr_raise(ret);
mp_obj_t val = mp_obj_exception_get_value(ret);
if (val == mp_const_none) {
return MP_OBJ_STOP_ITERATION;
}
}
nlr_raise(ret);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment