summaryrefslogtreecommitdiff
path: root/py/objtype.c
diff options
context:
space:
mode:
Diffstat (limited to 'py/objtype.c')
-rw-r--r--py/objtype.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/py/objtype.c b/py/objtype.c
index 0212a78da..ad68b85d2 100644
--- a/py/objtype.c
+++ b/py/objtype.c
@@ -34,6 +34,7 @@
#include "py/objtype.h"
#include "py/runtime.h"
+#include "supervisor/shared/stack.h"
#include "supervisor/shared/translate.h"
#if MICROPY_DEBUG_VERBOSE // print debugging info
@@ -186,14 +187,7 @@ STATIC void mp_obj_class_lookup(struct class_lookup_data *lookup, const mp_obj_
return;
} else {
mp_obj_instance_t *obj = lookup->obj;
- mp_obj_t obj_obj;
- if (obj != NULL && mp_obj_is_native_type(type) && type != &mp_type_object /* object is not a real type */) {
- // If we're dealing with native base class, then it applies to native sub-object
- obj_obj = obj->subobj[0];
- } else {
- obj_obj = MP_OBJ_FROM_PTR(obj);
- }
- mp_convert_member_lookup(obj_obj, type, elem->value, lookup->dest);
+ mp_convert_member_lookup(MP_OBJ_FROM_PTR(obj), type, elem->value, lookup->dest);
}
#if DEBUG_PRINT
printf("mp_obj_class_lookup: Returning: ");
@@ -851,8 +845,13 @@ STATIC mp_obj_t instance_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value
mp_obj_class_lookup(&lookup, self->base.type);
meth_args = 3;
}
- if (member[0] == MP_OBJ_SENTINEL) {
- return mp_obj_subscr(self->subobj[0], index, value);
+ if (member[0] == MP_OBJ_SENTINEL) { // native base subscr exists
+ mp_obj_type_t *subobj_type = mp_obj_get_type(self->subobj[0]);
+ // return mp_obj_subscr(self->subobj[0], index, value, instance);
+ mp_obj_t ret = subobj_type->subscr(self_in, index, value);
+ // May have called port specific C code. Make sure it didn't mess up the heap.
+ assert_heap_ok();
+ return ret;
} else if (member[0] != MP_OBJ_NULL) {
mp_obj_t args[3] = {self_in, index, value};
// TODO probably need to call mp_convert_member_lookup, and use mp_call_method_n_kw