diff options
author | Nnarol <lorand.l.juhasz@gmail.com> | 2023-01-08 13:51:20 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-08 13:51:20 (GMT) |
commit | 0741da8d28790cebe94a4392af37d63b1510080a (patch) | |
tree | 2d82f8d83605c596156738920288e81b75ef465a | |
parent | b034fd3e5926c63a681a211087b4c666834c7525 (diff) | |
download | cpython-0741da8d28790cebe94a4392af37d63b1510080a.zip cpython-0741da8d28790cebe94a4392af37d63b1510080a.tar.gz cpython-0741da8d28790cebe94a4392af37d63b1510080a.tar.bz2 |
GH-90829: Fix empty iterable error message in min/max (#31181)
-rw-r--r-- | Lib/test/test_builtin.py | 12 | ||||
-rw-r--r-- | 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 |