summaryrefslogtreecommitdiffstatshomepage
path: root/py/sequence.c
diff options
context:
space:
mode:
Diffstat (limited to 'py/sequence.c')
-rw-r--r--py/sequence.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/py/sequence.c b/py/sequence.c
index 07c0531b10..b3fb9fcd34 100644
--- a/py/sequence.c
+++ b/py/sequence.c
@@ -156,9 +156,10 @@ mp_obj_t mp_seq_index_obj(const mp_obj_t *items, uint len, uint n_args, const mp
}
for (uint i = start; i < stop; i++) {
- if (mp_obj_equal(items[i], value)) {
- return mp_obj_new_int_from_uint(i);
- }
+ if (mp_obj_equal(items[i], value)) {
+ // Common sense says this cannot overflow small int
+ return MP_OBJ_NEW_SMALL_INT(i);
+ }
}
nlr_jump(mp_obj_new_exception_msg(MP_QSTR_ValueError, "object not in sequence"));