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/mpstate.h | |
| 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/mpstate.h')
| -rw-r--r-- | py/mpstate.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/py/mpstate.h b/py/mpstate.h index e42d13fb2..07335bae4 100644 --- a/py/mpstate.h +++ b/py/mpstate.h @@ -266,6 +266,9 @@ typedef struct _mp_state_thread_t { // pending exception object (MP_OBJ_NULL if not pending) volatile mp_obj_t mp_pending_exception; + // If MP_OBJ_STOP_ITERATION is propagated then this holds its argument. + mp_obj_t stop_iteration_arg; + #if MICROPY_PY_SYS_SETTRACE mp_obj_t prof_trace_callback; bool prof_callback_is_executing; |
