diff options
author | Damien George <damien@micropython.org> | 2021-06-29 17:34:34 +1000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2021-07-15 00:12:41 +1000 |
commit | bb00125aaac8376b8cc4c8f3da2423fcf6dae496 (patch) | |
tree | 7a0d5f4de325776418beb96d9f27e46c5793597c /py/objgetitemiter.c | |
parent | e3825e28e61561427fd5811c1167e05ee3372eb4 (diff) |
py: Support single argument to optimised MP_OBJ_STOP_ITERATION.
The MP_OBJ_STOP_ITERATION optimisation is a shortcut for creating a
StopIteration() exception object, and means that heap memory does not need
to be allocated for the exception (in cases where it can be used). This
commit allows this optimised object to take an optional argument (before,
it could only have no argument).
The commit also adds some new tests to cover corner cases with
StopIteration and generators that previously did not work.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'py/objgetitemiter.c')
-rw-r--r-- | py/objgetitemiter.c | 1 |
1 files changed, 0 insertions, 1 deletions
diff --git a/py/objgetitemiter.c b/py/objgetitemiter.c index 2670314ab..31ed4a922 100644 --- a/py/objgetitemiter.c +++ b/py/objgetitemiter.c @@ -48,7 +48,6 @@ STATIC mp_obj_t it_iternext(mp_obj_t self_in) { // an exception was raised mp_obj_type_t *t = (mp_obj_type_t *)((mp_obj_base_t *)nlr.ret_val)->type; if (t == &mp_type_StopIteration || t == &mp_type_IndexError) { - // return MP_OBJ_STOP_ITERATION instead of raising return MP_OBJ_STOP_ITERATION; } else { // re-raise exception |