From 0741da8d28790cebe94a4392af37d63b1510080a Mon Sep 17 00:00:00 2001 From: Nnarol Date: Sun, 8 Jan 2023 14:51:20 +0100 Subject: GH-90829: Fix empty iterable error message in min/max (#31181) --- Lib/test/test_builtin.py | 12 ++++++++++-- Python/bltinmodule.c | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py index c656004..9e19af0 100644 --- a/Lib/test/test_builtin.py +++ b/Lib/test/test_builtin.py @@ -1155,7 +1155,11 @@ class BuiltinTest(unittest.TestCase): max() self.assertRaises(TypeError, max, 42) - self.assertRaises(ValueError, max, ()) + with self.assertRaisesRegex( + ValueError, + r'max\(\) iterable argument is empty' + ): + max(()) class BadSeq: def __getitem__(self, index): raise ValueError @@ -1214,7 +1218,11 @@ class BuiltinTest(unittest.TestCase): min() self.assertRaises(TypeError, min, 42) - self.assertRaises(ValueError, min, ()) + with self.assertRaisesRegex( + ValueError, + r'min\(\) iterable argument is empty' + ): + min(()) class BadSeq: def __getitem__(self, index): raise ValueError diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 599cc18..f97dd67 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -1814,7 +1814,7 @@ min_max(PyObject *args, PyObject *kwds, int op) maxitem = Py_NewRef(defaultval); } else { PyErr_Format(PyExc_ValueError, - "%s() arg is an empty sequence", name); + "%s() iterable argument is empty", name); } } else -- cgit v0.12