diff options
| author | Benjamin Peterson <benjamin@python.org> | 2010-03-21 20:21:00 +0000 |
|---|---|---|
| committer | Benjamin Peterson <benjamin@python.org> | 2010-03-21 20:21:00 +0000 |
| commit | ae062330a5216f5cc6f0bfa3f4351ae2e1f70494 (patch) | |
| tree | 4fc71ed147379b037470270469c8d5c49a833d17 /Python | |
| parent | e189b29cd5d4504778ba13c43585fb6f821a4329 (diff) | |
| download | cpython-ae062330a5216f5cc6f0bfa3f4351ae2e1f70494.tar.gz | |
improve error message from passing inadequate number of keyword arguments #6474
Note this removes the "non-keyword" or "keyword" phrases from these messages.
Diffstat (limited to 'Python')
| -rw-r--r-- | Python/ceval.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index 7ce3e514e1..4b0ff7ee22 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -3055,11 +3055,10 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals, if (!(co->co_flags & CO_VARARGS)) { PyErr_Format(PyExc_TypeError, "%.200s() takes %s %d " - "%sargument%s (%d given)", + "argument%s (%d given)", PyString_AsString(co->co_name), defcount ? "at most" : "exactly", co->co_argcount, - kwcount ? "non-keyword " : "", co->co_argcount == 1 ? "" : "s", argcount); goto fail; @@ -3150,15 +3149,18 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals, int m = co->co_argcount - defcount; for (i = argcount; i < m; i++) { if (GETLOCAL(i) == NULL) { + int j, given = 0; + for (j = 0; j < co->co_argcount; j++) + if (GETLOCAL(j)) + given++; PyErr_Format(PyExc_TypeError, "%.200s() takes %s %d " - "%sargument%s (%d given)", + "argument%s (%d given)", PyString_AsString(co->co_name), ((co->co_flags & CO_VARARGS) || defcount) ? "at least" : "exactly", - m, kwcount ? "non-keyword " : "", - m == 1 ? "" : "s", i); + m, m == 1 ? "" : "s", given); goto fail; } } |
