summaryrefslogtreecommitdiff
path: root/py/objtuple.c
diff options
context:
space:
mode:
authorTG-Techie <39284876+TG-Techie@users.noreply.github.com>2020-03-06 13:57:31 -0500
committerGitHub <noreply@github.com>2020-03-06 13:57:31 -0500
commit7198056bc31ebae22337af119c07c7dca03e85d5 (patch)
tree421b1c044250320ae15500f8578f6fec529937fa /py/objtuple.c
parent6d4ffc69fdfe19366b15861694f97cbf77452937 (diff)
parentba0c14f9ddf01f6cf98d278cbc4769a476342db0 (diff)
Merge pull request #2 from adafruit/5.0.x
5.0.x
Diffstat (limited to 'py/objtuple.c')
-rw-r--r--py/objtuple.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/py/objtuple.c b/py/objtuple.c
index ed13cdcef..0a2ed6f4c 100644
--- a/py/objtuple.c
+++ b/py/objtuple.c
@@ -29,6 +29,7 @@
#include "py/objtuple.h"
#include "py/runtime.h"
+#include "py/objtype.h"
#include "supervisor/shared/translate.h"
@@ -181,6 +182,11 @@ mp_obj_t mp_obj_tuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
if (value == MP_OBJ_SENTINEL) {
// load
mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in);
+ // when called with a native type (eg namedtuple) using mp_obj_tuple_subscr, get the native self
+ if (self->base.type->subscr != &mp_obj_tuple_subscr) {
+ self = mp_instance_cast_to_native_base(self_in, &mp_type_tuple);
+ }
+
#if MICROPY_PY_BUILTINS_SLICE
if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) {
mp_bound_slice_t slice;