summaryrefslogtreecommitdiffstatshomepage
path: root/py/objtuple.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2016-08-14 16:28:05 +1000
committerDamien George <damien.p.george@gmail.com>2016-08-14 16:28:05 +1000
commit4aaa5adf9f13dc875cd0eaadc2951a3b24c8cf15 (patch)
tree154ad1136558802aa4ae03a0e47139e3091b6fb3 /py/objtuple.c
parent9cf29493569d6292fc672e757b2aa96b42f1fe1d (diff)
downloadmicropython-4aaa5adf9f13dc875cd0eaadc2951a3b24c8cf15.tar.gz
micropython-4aaa5adf9f13dc875cd0eaadc2951a3b24c8cf15.zip
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.
Diffstat (limited to 'py/objtuple.c')
-rw-r--r--py/objtuple.c6
1 files changed, 2 insertions, 4 deletions
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) {