diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2016-08-12 22:06:47 +0300 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2016-08-12 22:39:03 +0300 |
commit | c4a8004933d1ae4da52f175d456d6fbe765c3923 (patch) | |
tree | 30aaeaf5a73c599a043ada8119fa3b8209837f9f /py/objtuple.c | |
parent | 83e0ebabb4c3c9144027609876ec62d428f8bba8 (diff) | |
download | micropython-c4a8004933d1ae4da52f175d456d6fbe765c3923.tar.gz micropython-c4a8004933d1ae4da52f175d456d6fbe765c3923.zip |
py: Get rid of assert() in method argument checking functions.
Checks for number of args removes where guaranteed by function descriptor,
self checking is replaced with mp_check_self(). In few cases, exception
is raised instead of assert.
Diffstat (limited to 'py/objtuple.c')
-rw-r--r-- | py/objtuple.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/py/objtuple.c b/py/objtuple.c index c21390a603..e7e24ab188 100644 --- a/py/objtuple.c +++ b/py/objtuple.c @@ -106,7 +106,7 @@ STATIC mp_obj_t mp_obj_tuple_make_new(const mp_obj_type_t *type_in, size_t n_arg 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) { - assert(0); + mp_raise_TypeError(""); } mp_obj_type_t *another_type = mp_obj_get_type(another_in); mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in); @@ -202,14 +202,14 @@ mp_obj_t mp_obj_tuple_getiter(mp_obj_t o_in) { } STATIC mp_obj_t tuple_count(mp_obj_t self_in, mp_obj_t value) { - assert(MP_OBJ_IS_TYPE(self_in, &mp_type_tuple)); + mp_check_self(MP_OBJ_IS_TYPE(self_in, &mp_type_tuple)); mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in); return mp_seq_count_obj(self->items, self->len, value); } STATIC MP_DEFINE_CONST_FUN_OBJ_2(tuple_count_obj, tuple_count); STATIC mp_obj_t tuple_index(size_t n_args, const mp_obj_t *args) { - assert(MP_OBJ_IS_TYPE(args[0], &mp_type_tuple)); + mp_check_self(MP_OBJ_IS_TYPE(args[0], &mp_type_tuple)); mp_obj_tuple_t *self = MP_OBJ_TO_PTR(args[0]); return mp_seq_index_obj(self->items, self->len, n_args, args); } |