diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-04-13 11:24:14 +0300 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-04-13 11:30:16 +0300 |
commit | 1a37588e35ac2a585dc528bcb336b7bb1793065f (patch) | |
tree | 52b49c060a4de65fde2f3fac0aa1dd7de4da9a89 /py/objfun.c | |
parent | 48fdaad824da690088ad164326c3151a7bb77432 (diff) | |
download | micropython-1a37588e35ac2a585dc528bcb336b7bb1793065f.tar.gz micropython-1a37588e35ac2a585dc528bcb336b7bb1793065f.zip |
py: Provide more details for too few and too much args for Python fun calls.
Diffstat (limited to 'py/objfun.c')
-rw-r--r-- | py/objfun.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/py/objfun.c b/py/objfun.c index 4ef92c0256..056789c336 100644 --- a/py/objfun.c +++ b/py/objfun.c @@ -229,7 +229,8 @@ STATIC mp_obj_t fun_bc_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_o if (n_args > self->n_args) { // given more than enough arguments if (!self->takes_var_args) { - goto arg_error; + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, + "function takes %d positional arguments but %d were given", self->n_args, n_args)); } // put extra arguments in varargs tuple *extra_args = mp_obj_new_tuple(n_args - self->n_args, args + self->n_args); @@ -249,7 +250,9 @@ STATIC mp_obj_t fun_bc_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_o extra_args -= self->n_args - n_args; n_extra_args += self->n_args - n_args; } else { - goto arg_error; + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, + "function takes at least %d positional arguments but %d were given", + self->n_args - self->n_def_args, n_args)); } } } @@ -344,9 +347,6 @@ continue2:; } else { // MP_VM_RETURN_EXCEPTION nlr_raise(result); } - -arg_error: - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, "function takes %d positional arguments but %d were given", self->n_args, n_args)); } const mp_obj_type_t mp_type_fun_bc = { |