mirror of
https://github.com/python/cpython.git
synced 2025-09-08 01:41:19 +00:00
bpo-36282: Improved error message for too much positional arguments. (GH-12310)
This commit is contained in:
parent
d53fe5f407
commit
f2f55e7f03
3 changed files with 4 additions and 2 deletions
|
@ -157,7 +157,7 @@ class CFunctionCallsErrorMessages(unittest.TestCase):
|
||||||
self.assertRaisesRegex(TypeError, msg, {}.__contains__, 0, 1)
|
self.assertRaisesRegex(TypeError, msg, {}.__contains__, 0, 1)
|
||||||
|
|
||||||
def test_varargs3(self):
|
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)
|
self.assertRaisesRegex(TypeError, msg, int.from_bytes, b'a', 'little', False)
|
||||||
|
|
||||||
def test_varargs1min(self):
|
def test_varargs1min(self):
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
Improved error message for too much positional arguments in some builtin
|
||||||
|
functions.
|
|
@ -2137,7 +2137,7 @@ vgetargskeywordsfast_impl(PyObject *const *args, Py_ssize_t nargs,
|
||||||
"%.200s%s takes %s %d positional argument%s (%d given)",
|
"%.200s%s takes %s %d positional argument%s (%d given)",
|
||||||
(parser->fname == NULL) ? "function" : parser->fname,
|
(parser->fname == NULL) ? "function" : parser->fname,
|
||||||
(parser->fname == NULL) ? "" : "()",
|
(parser->fname == NULL) ? "" : "()",
|
||||||
(parser->min != INT_MAX) ? "at most" : "exactly",
|
(parser->min < parser->max) ? "at most" : "exactly",
|
||||||
parser->max,
|
parser->max,
|
||||||
parser->max == 1 ? "" : "s",
|
parser->max == 1 ? "" : "s",
|
||||||
nargs);
|
nargs);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue