Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
1a37588e
Commit
1a37588e
authored
Apr 13, 2014
by
Paul Sokolovsky
Browse files
py: Provide more details for too few and too much args for Python fun calls.
parent
48fdaad8
Changes
1
Hide whitespace changes
Inline
Side-by-side
py/objfun.c
View file @
1a37588e
...
...
@@ -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
=
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment