Index: Objects/listobject.c =================================================================== --- Objects/listobject.c (revision 61626) +++ Objects/listobject.c (working copy) @@ -2037,7 +2037,7 @@ } if (compare == Py_None) compare = NULL; - if (compare == NULL && + if (compare != NULL && Py_Py3kWarningFlag && PyErr_Warn(PyExc_DeprecationWarning, "In 3.x, the cmp argument is no longer supported.") < 0) Index: Lib/test/test_py3kwarn.py =================================================================== --- Lib/test/test_py3kwarn.py (revision 61626) +++ Lib/test/test_py3kwarn.py (working copy) @@ -90,6 +90,16 @@ with catch_warning() as w: self.assertWarning(meth >= func, w, expected) + def test_sort_cmp_arg(self): + expected = "In 3.x, the cmp argument is no longer supported." + lst = range(5) + cmp = lambda x,y: -1 + + with catch_warning() as w: + self.assertWarning(lst.sort(cmp=cmp), w, expected) + with catch_warning() as w: + self.assertWarning(sorted(lst, cmp=cmp), w, expected) + def assertWarning(self, _, warning, expected_message): self.assertEqual(str(warning.message), expected_message)