@@ -160,11 +160,11 @@ STATIC mp_obj_t list_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) {
160160
161161#pragma GCC diagnostic ignored "-Wunused-parameter"
162162STATIC mp_obj_t list_subscr (mp_obj_t self_in , mp_obj_t index , mp_obj_t value , mp_obj_t instance ) {
163+ mp_obj_list_t * self = mp_instance_cast_to_native_base (self_in , & mp_type_list );
163164 if (value == MP_OBJ_NULL ) {
164165 // delete
165166#if MICROPY_PY_BUILTINS_SLICE
166167 if (MP_OBJ_IS_TYPE (index , & mp_type_slice )) {
167- mp_obj_list_t * self = MP_OBJ_TO_PTR (self_in );
168168 mp_bound_slice_t slice ;
169169 if (!mp_seq_get_fast_slice_indexes (self -> len , index , & slice )) {
170170 mp_raise_NotImplementedError (NULL );
@@ -180,12 +180,11 @@ STATIC mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp
180180 return mp_const_none ;
181181 }
182182#endif
183- mp_obj_t args [2 ] = {self_in , index };
183+ mp_obj_t args [2 ] = {self , index };
184184 list_pop (2 , args );
185185 return mp_const_none ;
186186 } else if (value == MP_OBJ_SENTINEL ) {
187187 // load
188- mp_obj_list_t * self = MP_OBJ_TO_PTR (self_in );
189188#if MICROPY_PY_BUILTINS_SLICE
190189 if (MP_OBJ_IS_TYPE (index , & mp_type_slice )) {
191190 mp_bound_slice_t slice ;
@@ -202,7 +201,6 @@ STATIC mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp
202201 } else {
203202#if MICROPY_PY_BUILTINS_SLICE
204203 if (MP_OBJ_IS_TYPE (index , & mp_type_slice )) {
205- mp_obj_list_t * self = MP_OBJ_TO_PTR (self_in );
206204 size_t value_len ; mp_obj_t * value_items ;
207205 mp_obj_get_array (value , & value_len , & value_items );
208206 mp_bound_slice_t slice_out ;
@@ -231,7 +229,7 @@ STATIC mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp
231229 return mp_const_none ;
232230 }
233231#endif
234- mp_obj_list_store (self_in , index , value );
232+ mp_obj_list_store (self , index , value );
235233 return mp_const_none ;
236234 }
237235}
0 commit comments