Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fd39ad4

Browse files
committed
Patch #1005468: Disambiguate "min() or max()" exception string.
1 parent 9ecf326 commit fd39ad4

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

Python/bltinmodule.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,11 +1116,12 @@ Update and return a dictionary containing the current scope's local variables.")
11161116
static PyObject *
11171117
min_max(PyObject *args, int op)
11181118
{
1119+
const char *name = op == Py_LT ? "min" : "max";
11191120
PyObject *v, *w, *x, *it;
11201121

11211122
if (PyTuple_Size(args) > 1)
11221123
v = args;
1123-
else if (!PyArg_UnpackTuple(args, (op==Py_LT) ? "min" : "max", 1, 1, &v))
1124+
else if (!PyArg_UnpackTuple(args, (char *)name, 1, 1, &v))
11241125
return NULL;
11251126

11261127
it = PyObject_GetIter(v);
@@ -1158,8 +1159,8 @@ min_max(PyObject *args, int op)
11581159
}
11591160
}
11601161
if (w == NULL)
1161-
PyErr_SetString(PyExc_ValueError,
1162-
"min() or max() arg is an empty sequence");
1162+
PyErr_Format(PyExc_ValueError,
1163+
"%s() arg is an empty sequence", name);
11631164
Py_DECREF(it);
11641165
return w;
11651166
}

0 commit comments

Comments
 (0)