Mercurial > cpython-lru_cache-weakref
diff Python/ceval.c @ 59853:651a8e5c460f legacy-trunk
improve error message from passing inadequate number of keyword arguments #6474
Note this removes the "non-keyword" or "keyword" phrases from these messages.
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Sun, 21 Mar 2010 20:21:00 +0000 |
| parents | 0d1cdd14c9fa |
| children | dbad1c0668c9 |
line wrap: on
line diff
--- a/Python/ceval.c Sun Mar 21 19:56:37 2010 +0000 +++ b/Python/ceval.c Sun Mar 21 20:21:00 2010 +0000 @@ -3055,11 +3055,10 @@ 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 @@ 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; } }
