Commit 0c1ea269 authored by Guido van Rossum's avatar Guido van Rossum

Give more detailed error message when the argument count isn't right.

parent 0db57aca
...@@ -454,8 +454,9 @@ eval_code2(co, globals, locals, ...@@ -454,8 +454,9 @@ eval_code2(co, globals, locals,
} }
if (argcount > co->co_argcount) { if (argcount > co->co_argcount) {
if (!(co->co_flags & CO_VARARGS)) { if (!(co->co_flags & CO_VARARGS)) {
PyErr_SetString(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
"too many arguments"); "too many arguments; expected %d, got %d",
co->co_argcount, argcount);
goto fail; goto fail;
} }
n = co->co_argcount; n = co->co_argcount;
...@@ -513,8 +514,9 @@ eval_code2(co, globals, locals, ...@@ -513,8 +514,9 @@ eval_code2(co, globals, locals,
int m = co->co_argcount - defcount; int m = co->co_argcount - defcount;
for (i = argcount; i < m; i++) { for (i = argcount; i < m; i++) {
if (GETLOCAL(i) == NULL) { if (GETLOCAL(i) == NULL) {
PyErr_SetString(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
"not enough arguments"); "not enough arguments; expected %d, got %d",
m, i);
goto fail; goto fail;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment