Skip to content

Commit 275c1f5

Browse files
author
raymond.hettinger
committed
Issue: 2354: Add 3K warning for the cmp argument to list.sort() and sorted().
git-svn-id: http://svn.python.org/projects/python/trunk@61576 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 284c8c2 commit 275c1f5

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)