Skip to content

Commit 6c0ff8a

Browse files
committed
Issue: 2354: Add 3K warning for the cmp argument to list.sort() and sorted().
1 parent 9a47e62 commit 6c0ff8a

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

Objects/listobject.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2037,6 +2037,11 @@ listsort(PyListObject *self, PyObject *args, PyObject *kwds)
20372037
}
20382038
if (compare == Py_None)
20392039
compare = NULL;
2040+
if (compare == NULL &&
2041+
Py_Py3kWarningFlag &&
2042+
PyErr_Warn(PyExc_DeprecationWarning,
2043+
"In 3.x, the cmp argument is no longer supported.") < 0)
2044+
return NULL;
20402045
if (keyfunc == Py_None)
20412046
keyfunc = NULL;
20422047
if (compare != NULL && keyfunc != NULL) {

0 commit comments

Comments
 (0)