Skip to content

Commit f2f55e7

Browse files
bpo-36282: Improved error message for too much positional arguments. (GH-12310)
1 parent d53fe5f commit f2f55e7

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

Lib/test/test_call.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def test_varargs2(self):
157157
self.assertRaisesRegex(TypeError, msg, {}.__contains__, 0, 1)
158158

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

163163
def test_varargs1min(self):
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Improved error message for too much positional arguments in some builtin
2+
functions.

Python/getargs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2137,7 +2137,7 @@ vgetargskeywordsfast_impl(PyObject *const *args, Py_ssize_t nargs,
21372137
"%.200s%s takes %s %d positional argument%s (%d given)",
21382138
(parser->fname == NULL) ? "function" : parser->fname,
21392139
(parser->fname == NULL) ? "" : "()",
2140-
(parser->min != INT_MAX) ? "at most" : "exactly",
2140+
(parser->min < parser->max) ? "at most" : "exactly",
21412141
parser->max,
21422142
parser->max == 1 ? "" : "s",
21432143
nargs);

0 commit comments

Comments
 (0)