@@ -488,15 +488,14 @@ mp_obj_t mp_obj_len_maybe(mp_obj_t o_in) {
488488}
489489
490490mp_obj_t mp_obj_subscr (mp_obj_t base , mp_obj_t index , mp_obj_t value ) {
491+ return mp_obj_subscr_impl (base , index , value , base );
492+ }
493+
494+ mp_obj_t mp_obj_subscr_impl (mp_obj_t base , mp_obj_t index , mp_obj_t value , mp_obj_t instance ) {
491495 mp_obj_type_t * type = mp_obj_get_type (base );
492- mp_obj_t instance = base ;
493- // If we got an MP_OBJ_SENTINEL as the type, then we got called by instance_subscr
494- if (type == MP_OBJ_SENTINEL ) {
495- instance = ((mp_obj_t * )base )[1 ];
496- type = mp_obj_get_type (((mp_obj_t * )base )[2 ]);
497- }
496+
498497 if (type -> subscr != NULL ) {
499- mp_obj_t ret = type -> subscr (instance , index , value );
498+ mp_obj_t ret = type -> subscr (base , index , value , instance );
500499 // May have called port specific C code. Make sure it didn't mess up the heap.
501500 assert_heap_ok ();
502501 if (ret != MP_OBJ_NULL ) {
@@ -551,7 +550,7 @@ STATIC mp_obj_t generic_it_iternext(mp_obj_t self_in) {
551550 mp_obj_type_t * type = mp_obj_get_type (self -> obj );
552551 mp_obj_t current_length = type -> unary_op (MP_UNARY_OP_LEN , self -> obj );
553552 if (self -> cur < MP_OBJ_SMALL_INT_VALUE (current_length )) {
554- mp_obj_t o_out = type -> subscr (self -> obj , MP_OBJ_NEW_SMALL_INT (self -> cur ), MP_OBJ_SENTINEL );
553+ mp_obj_t o_out = type -> subscr (self -> obj , MP_OBJ_NEW_SMALL_INT (self -> cur ), MP_OBJ_SENTINEL , self -> obj );
555554 self -> cur += 1 ;
556555 return o_out ;
557556 } else {
0 commit comments