From 4aaa5adf9f13dc875cd0eaadc2951a3b24c8cf15 Mon Sep 17 00:00:00 2001 From: Damien George Date: Sun, 14 Aug 2016 16:28:05 +1000 Subject: py/objtuple: In tuple_cmp_helper, use mp_check_self instead of raising. Only tuple, namedtuple and attrtuple use the tuple_cmp_helper function, and they all have getiter=mp_obj_tuple_getiter, so the check here is only to ensure that the self object is consistent. Hence use mp_check_self. --- py/objtuple.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'py/objtuple.c') diff --git a/py/objtuple.c b/py/objtuple.c index e7e24ab188..c547da9406 100644 --- a/py/objtuple.c +++ b/py/objtuple.c @@ -104,10 +104,8 @@ STATIC mp_obj_t mp_obj_tuple_make_new(const mp_obj_type_t *type_in, size_t n_arg // Don't pass MP_BINARY_OP_NOT_EQUAL here STATIC bool tuple_cmp_helper(mp_uint_t op, mp_obj_t self_in, mp_obj_t another_in) { - mp_obj_type_t *self_type = mp_obj_get_type(self_in); - if (self_type->getiter != mp_obj_tuple_getiter) { - mp_raise_TypeError(""); - } + // 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_type_t *another_type = mp_obj_get_type(another_in); mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in); if (another_type->getiter != mp_obj_tuple_getiter) { -- cgit v1.2.3