bpo-36282: Improved error message for too much positional arguments. by serhiy-storchaka · Pull Request #12310 · python/cpython

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-36282: Improved error message for too much positional arguments. #12310

Changes from all commits

Commits

File filter

Filter by extension

Conversations

Failed to load comments.

Loading

Jump to

Jump to file

Failed to load files.

Loading

Diff view
Diff view

2 changes: 1 addition & 1 deletion Lib/test/test_call.py

Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def test_varargs2(self):
self.assertRaisesRegex(TypeError, msg, {}.__contains__, 0, 1)

def test_varargs3(self):
msg = r"^from_bytes\(\) takes at most 2 positional arguments \(3 given\)"
msg = r"^from_bytes\(\) takes exactly 2 positional arguments \(3 given\)"
self.assertRaisesRegex(TypeError, msg, int.from_bytes, b'a', 'little', False)

def test_varargs1min(self):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Improved error message for too much positional arguments in some builtin
functions.

2 changes: 1 addition & 1 deletion Python/getargs.c

Original file line number Diff line number Diff line change
Expand Up @@ -2137,7 +2137,7 @@ vgetargskeywordsfast_impl(PyObject *const *args, Py_ssize_t nargs,
"%.200s%s takes %s %d positional argument%s (%d given)",
(parser->fname == NULL) ? "function" : parser->fname,
(parser->fname == NULL) ? "" : "()",
(parser->min != INT_MAX) ? "at most" : "exactly",
(parser->min < parser->max) ? "at most" : "exactly",
parser->max,
parser->max == 1 ? "" : "s",
nargs);
Expand Down