Fix regression in error message introduced in bpo-29951. (#2028)

* Fix regression in error message introduced in bpo-29951.

* Add test.

* Make the test more strong.
This commit is contained in:
Serhiy Storchaka 2017-06-09 19:27:06 +03:00 committed by Victor Stinner
parent 57161aac5e
commit f9f1ccace3
2 changed files with 6 additions and 2 deletions

View file

@ -2089,13 +2089,13 @@ vgetargskeywordsfast_impl(PyObject **args, Py_ssize_t nargs,
if (parser->max < nargs) {
if (parser->max == 0) {
PyErr_Format(PyExc_TypeError,
"%200s%s takes no positional arguments",
"%.200s%s takes no positional arguments",
(parser->fname == NULL) ? "function" : parser->fname,
(parser->fname == NULL) ? "" : "()");
}
else {
PyErr_Format(PyExc_TypeError,
"%200s%s takes %s %d positional arguments (%d given)",
"%.200s%s takes %s %d positional arguments (%d given)",
(parser->fname == NULL) ? "function" : parser->fname,
(parser->fname == NULL) ? "" : "()",
(parser->min != INT_MAX) ? "at most" : "exactly",