From 3eb418af39ad6151c9af4caf5c129397c7c14f67 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sat, 10 Aug 2019 10:10:41 -0500 Subject: [PATCH] py: mp_obj_tuple_get: accept any item which can use tuple_getiter .. such as namedtuple and attrtuple objects. This is the same predicate used elsewhere in the file to check for adequate compatibility between the types. This was discovered due to crashing `time.time()` on the nrf port. Closes: #2052 --- py/objtuple.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/py/objtuple.c b/py/objtuple.c index 474f81c1a5..ed13cdcef2 100644 --- a/py/objtuple.c +++ b/py/objtuple.c @@ -251,7 +251,8 @@ mp_obj_t mp_obj_new_tuple(size_t n, const mp_obj_t *items) { } void mp_obj_tuple_get(mp_obj_t self_in, size_t *len, mp_obj_t **items) { - assert(MP_OBJ_IS_TYPE(self_in, &mp_type_tuple)); + // type check is done on getiter method to allow tuple, namedtuple, attrtuple + mp_check_self(mp_obj_get_type(self_in)->getiter == mp_obj_tuple_getiter); mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in); *len = self->len; *items = &self->items[0];