Skip to content

Commit 6433f71

Browse files
pramasouldpgeorge
authored andcommitted
py/objgetitemiter: Make it_iternext() recognize IndexError.
1 parent a3fe307 commit 6433f71

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

py/objgetitemiter.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ STATIC mp_obj_t it_iternext(mp_obj_t self_in) {
4747
return value;
4848
} else {
4949
// an exception was raised
50-
if (mp_obj_get_type(nlr.ret_val) == &mp_type_StopIteration) {
51-
// return MP_OBJ_STOP_ITERATION instead of raising StopIteration
50+
mp_obj_type_t *t = mp_obj_get_type(nlr.ret_val);
51+
if (t == &mp_type_StopIteration || t == &mp_type_IndexError) {
52+
// return MP_OBJ_STOP_ITERATION instead of raising
5253
return MP_OBJ_STOP_ITERATION;
5354
} else {
5455
// re-raise exception

0 commit comments

Comments
 (0)