Skip to content

Commit

Permalink
py/objtuple: In tuple_cmp_helper, use mp_check_self instead of raising.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dpgeorge committed Aug 14, 2016
1 parent 9cf2949 commit 4aaa5ad
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions py/objtuple.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 4aaa5ad

Please sign in to comment.