From ee7a880d6e669423309c3a5f8c20b59027604572 Mon Sep 17 00:00:00 2001 From: Damien George Date: Sun, 11 May 2014 18:37:21 +0100 Subject: py: Use mp_arg_check_num in more places. Updated functions now do proper checking that n_kw==0, and are simpler because they don't have to explicitly raise an exception. Down side is that the error messages no longer include the function name, but that's acceptable. Saves order 300 text bytes on x64 and ARM. --- py/objtuple.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'py/objtuple.c') diff --git a/py/objtuple.c b/py/objtuple.c index 1ec75239bd..44ee95dd96 100644 --- a/py/objtuple.c +++ b/py/objtuple.c @@ -57,14 +57,15 @@ void mp_obj_tuple_print(void (*print)(void *env, const char *fmt, ...), void *en } STATIC mp_obj_t mp_obj_tuple_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) { - // TODO check n_kw == 0 + mp_arg_check_num(n_args, n_kw, 0, 1, false); switch (n_args) { case 0: // return a empty tuple return mp_const_empty_tuple; - case 1: { + case 1: + default: { // 1 argument, an iterable from which we make a new tuple if (MP_OBJ_IS_TYPE(args[0], &mp_type_tuple)) { return args[0]; @@ -91,9 +92,6 @@ STATIC mp_obj_t mp_obj_tuple_make_new(mp_obj_t type_in, uint n_args, uint n_kw, return tuple; } - - default: - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, "tuple takes at most 1 argument, %d given", n_args)); } } -- cgit v1.2.3