Commit 953c23b1 authored by Damien George's avatar Damien George
Browse files

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 #1294.
parent 181adc6a
...@@ -1044,6 +1044,7 @@ mp_obj_t mp_iternext_allow_raise(mp_obj_t o_in) { ...@@ -1044,6 +1044,7 @@ mp_obj_t mp_iternext_allow_raise(mp_obj_t o_in) {
// will always return MP_OBJ_STOP_ITERATION instead of raising StopIteration() (or any subclass thereof) // will always return MP_OBJ_STOP_ITERATION instead of raising StopIteration() (or any subclass thereof)
// may raise other exceptions // may raise other exceptions
mp_obj_t mp_iternext(mp_obj_t o_in) { mp_obj_t mp_iternext(mp_obj_t o_in) {
MP_STACK_CHECK(); // enumerate, filter, map and zip can recursively call mp_iternext
mp_obj_type_t *type = mp_obj_get_type(o_in); mp_obj_type_t *type = mp_obj_get_type(o_in);
if (type->iternext != NULL) { if (type->iternext != NULL) {
return type->iternext(o_in); return type->iternext(o_in);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment