Skip to content

Commit 15072c6

Browse files
committed
push changes
1 parent cc31f2d commit 15072c6

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

extmod/modbtree.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,8 @@ STATIC mp_obj_t btree_iternext(mp_obj_t self_in) {
248248

249249
#pragma GCC diagnostic ignored "-Wunused-parameter"
250250
STATIC mp_obj_t btree_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) {
251-
mp_obj_btree_t *self = MP_OBJ_TO_PTR(self_in);
251+
//mp_obj_btree_t *self = MP_OBJ_TO_PTR(self_in);
252+
mp_obj_btree_t *self = mp_instance_cast_to_native_base(self_in, &btree_type);
252253
if (value == MP_OBJ_NULL) {
253254
// delete
254255
DBT key;

extmod/moductypes.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,8 +519,8 @@ STATIC void uctypes_struct_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
519519
}
520520

521521
#pragma GCC diagnostic ignored "-Wunused-parameter"
522-
STATIC mp_obj_t uctypes_struct_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value, mp_obj_t instance) {
523-
mp_obj_uctypes_struct_t *self = MP_OBJ_TO_PTR(self_in);
522+
STATIC mp_obj_t uctypes_struct_subscr(mp_obj_t base_in, mp_obj_t index_in, mp_obj_t value, mp_obj_t instance) {
523+
mp_obj_uctypes_struct_t *self = mp_instance_cast_to_native_base(base_in, &uctypes_struct_type);
524524

525525
if (value == MP_OBJ_NULL) {
526526
// delete

py/objlist.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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"
162162
STATIC 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
}

py/objtype.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "py/objtype.h"
3535
#include "py/runtime.h"
3636

37+
#include "supervisor/shared/stack.h"
3738
#include "supervisor/shared/translate.h"
3839

3940
#if MICROPY_DEBUG_VERBOSE // print debugging info
@@ -851,8 +852,13 @@ STATIC mp_obj_t instance_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value
851852
mp_obj_class_lookup(&lookup, self->base.type);
852853
meth_args = 3;
853854
}
854-
if (member[0] == MP_OBJ_SENTINEL) {
855-
return mp_obj_subscr(self->subobj[0], index, value, instance);
855+
if (member[0] == MP_OBJ_SENTINEL) { // native base subscr exists
856+
mp_obj_type_t *subobj_type = mp_obj_get_type(self->subobj[0]);
857+
// return mp_obj_subscr(self->subobj[0], index, value, instance);
858+
mp_obj_t ret = subobj_type->subscr(self_in, index, value, instance);
859+
// May have called port specific C code. Make sure it didn't mess up the heap.
860+
assert_heap_ok();
861+
return ret;
856862
} else if (member[0] != MP_OBJ_NULL) {
857863
mp_obj_t args[3] = {self_in, index, value};
858864
// TODO probably need to call mp_convert_member_lookup, and use mp_call_method_n_kw

0 commit comments

Comments
 (0)