Allow list sort's comparison function to explicitly be None. See SF patch

661092.
This commit is contained in:
Skip Montanaro 2003-01-02 20:51:08 +00:00
parent fe8496ca03
commit 4abd5f0fce
4 changed files with 34 additions and 6 deletions

View file

@ -1657,6 +1657,9 @@ listsort(PyListObject *self, PyObject *args)
if (!PyArg_UnpackTuple(args, "sort", 0, 1, &compare))
return NULL;
}
if (compare == Py_None)
compare = NULL;
merge_init(&ms, compare);
/* The list is temporarily made empty, so that mutations performed
@ -2069,7 +2072,7 @@ PyDoc_STRVAR(count_doc,
PyDoc_STRVAR(reverse_doc,
"L.reverse() -- reverse *IN PLACE*");
PyDoc_STRVAR(sort_doc,
"L.sort([cmpfunc]) -- stable sort *IN PLACE*; cmpfunc(x, y) -> -1, 0, 1");
"L.sort(cmpfunc=None) -- stable sort *IN PLACE*; cmpfunc(x, y) -> -1, 0, 1");
static PyMethodDef list_methods[] = {
{"append", (PyCFunction)listappend, METH_O, append_doc},