Skip to content

Commit 953c23b

Browse files
committed
py: Add stack check to mp_iternext, since it can be called recursively.
Eg, builtin map can map over a map, etc, and call iternext deeply. Addresses issue adafruit#1294.
1 parent 181adc6 commit 953c23b

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

py/runtime.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,6 +1044,7 @@ mp_obj_t mp_iternext_allow_raise(mp_obj_t o_in) {
10441044
// will always return MP_OBJ_STOP_ITERATION instead of raising StopIteration() (or any subclass thereof)
10451045
// may raise other exceptions
10461046
mp_obj_t mp_iternext(mp_obj_t o_in) {
1047+
MP_STACK_CHECK(); // enumerate, filter, map and zip can recursively call mp_iternext
10471048
mp_obj_type_t *type = mp_obj_get_type(o_in);
10481049
if (type->iternext != NULL) {
10491050
return type->iternext(o_in);

0 commit comments

Comments
 (0)