From abdc634f337ce4943cd7d13587936837aac2ecc9 Mon Sep 17 00:00:00 2001 From: Dong-hee Na Date: Sat, 11 Jan 2020 01:31:43 +0900 Subject: bpo-39200: Correct the error message for min/max builtin function (GH-17814) Correct the error message when calling the min() or max() with no arguments. --- Python/bltinmodule.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'Python/bltinmodule.c') diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 34267685be2..4f833c1f462 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -1589,10 +1589,15 @@ min_max(PyObject *args, PyObject *kwds, int op) const int positional = PyTuple_Size(args) > 1; int ret; - if (positional) + if (positional) { v = args; - else if (!PyArg_UnpackTuple(args, name, 1, 1, &v)) + } + else if (!PyArg_UnpackTuple(args, name, 1, 1, &v)) { + if (PyExceptionClass_Check(PyExc_TypeError)) { + PyErr_Format(PyExc_TypeError, "%s expected at least 1 argument, got 0", name); + } return NULL; + } emptytuple = PyTuple_New(0); if (emptytuple == NULL) -- cgit v1.2.3