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.
This commit is contained in:
Damien George 2016-08-14 16:28:05 +10:00
parent 9cf2949356
commit 4aaa5adf9f

View File

@ -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 // 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) { 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); // type check is done on getiter method to allow tuple, namedtuple, attrtuple
if (self_type->getiter != mp_obj_tuple_getiter) { mp_check_self(mp_obj_get_type(self_in)->getiter == mp_obj_tuple_getiter);
mp_raise_TypeError("");
}
mp_obj_type_t *another_type = mp_obj_get_type(another_in); mp_obj_type_t *another_type = mp_obj_get_type(another_in);
mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in); mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in);
if (another_type->getiter != mp_obj_tuple_getiter) { if (another_type->getiter != mp_obj_tuple_getiter) {