From: Raymond Hettinger Date: Tue, 18 Mar 2008 23:33:08 +0000 (+0000) Subject: Issue: 2354: Add 3K warning for the cmp argument to list.sort() and sorted(). X-Git-Tag: v2.6a2~249 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6c0ff8aacd5b493892878e138b97af66e4bfaf37;p=python Issue: 2354: Add 3K warning for the cmp argument to list.sort() and sorted(). --- diff --git a/Objects/listobject.c b/Objects/listobject.c index 9a8b64e76f..9e86592101 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -2037,6 +2037,11 @@ listsort(PyListObject *self, PyObject *args, PyObject *kwds) } if (compare == Py_None) compare = NULL; + if (compare == NULL && + Py_Py3kWarningFlag && + PyErr_Warn(PyExc_DeprecationWarning, + "In 3.x, the cmp argument is no longer supported.") < 0) + return NULL; if (keyfunc == Py_None) keyfunc = NULL; if (compare != NULL && keyfunc != NULL) {