File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -182,13 +182,17 @@ static mp_obj_t list_index(int n_args, const mp_obj_t *args) {
182182 assert (MP_OBJ_IS_TYPE (args [0 ], & list_type ));
183183 mp_obj_list_t * self = args [0 ];
184184 mp_obj_t * value = args [1 ];
185+ uint start = 0 ;
186+ uint stop = self -> len ;
185187
186- uint start = mp_get_index (self -> base .type , self -> len ,
187- n_args >= 3 ? args [2 ] : mp_obj_new_int (0 ));
188- uint stop = mp_get_index (self -> base .type , self -> len ,
189- n_args >= 4 ? args [3 ] : mp_obj_new_int (-1 ));
188+ if (n_args >= 3 ) {
189+ start = mp_get_index (self -> base .type , self -> len , args [2 ]);
190+ if (n_args >= 4 ) {
191+ stop = mp_get_index (self -> base .type , self -> len , args [3 ]);
192+ }
193+ }
190194
191- for (uint i = start ; i <= stop ; i ++ ) {
195+ for (uint i = start ; i < stop ; i ++ ) {
192196 if (mp_obj_equal (self -> items [i ], value )) {
193197 return mp_obj_new_int (i );
194198 }
You can’t perform that action at this time.
0 commit comments