From f2f55e7f03d332fd43bc665a86d585a79c3b3ed4 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Wed, 13 Mar 2019 23:03:22 +0200 Subject: bpo-36282: Improved error message for too much positional arguments. (GH-12310) --- Lib/test/test_call.py | 2 +- .../next/Core and Builtins/2019-03-13-22-47-28.bpo-36282.zs7RKP.rst | 2 ++ Python/getargs.c | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2019-03-13-22-47-28.bpo-36282.zs7RKP.rst diff --git a/Lib/test/test_call.py b/Lib/test/test_call.py index 75a4a9f..0da0719 100644 --- a/Lib/test/test_call.py +++ b/Lib/test/test_call.py @@ -157,7 +157,7 @@ class CFunctionCallsErrorMessages(unittest.TestCase): 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): diff --git a/Misc/NEWS.d/next/Core and Builtins/2019-03-13-22-47-28.bpo-36282.zs7RKP.rst b/Misc/NEWS.d/next/Core and Builtins/2019-03-13-22-47-28.bpo-36282.zs7RKP.rst new file mode 100644 index 0000000..f9ec51e --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2019-03-13-22-47-28.bpo-36282.zs7RKP.rst @@ -0,0 +1,2 @@ +Improved error message for too much positional arguments in some builtin +functions. diff --git a/Python/getargs.c b/Python/getargs.c index 876f5c7..77ded60 100644 --- a/Python/getargs.c +++ b/Python/getargs.c @@ -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); -- cgit v0.12