This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients daniel.urban, eric.smith, gruszczy, ncoghlan, python-dev, rhettinger, stutzbach, terry.reedy, vstinner
Date 2011-04-05.10:33:55
SpamBayes Score 2.0709842e-06
Marked as misclassified No
Message-id <1301999635.94.0.261193311165.issue11707@psf.upfronthosting.co.za>
In-reply-to
Content
functools_cmp_to_key() doesn't check that the argument is a callable.

>>> table=list(range(3))
>>> table.sort(key=functools.cmp_to_key(3))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'int' object is not callable

PyCallable_Check() should be used, something like:

    if (!PyCallable_Check(cmp)) {
        PyErr_SetString(PyExc_TypeError, "parameter must be callable");
        return NULL;
    }
History
Date User Action Args
2011-04-05 10:33:56vstinnersetrecipients: + vstinner, rhettinger, terry.reedy, ncoghlan, eric.smith, stutzbach, gruszczy, daniel.urban, python-dev
2011-04-05 10:33:55vstinnersetmessageid: <1301999635.94.0.261193311165.issue11707@psf.upfronthosting.co.za>
2011-04-05 10:33:55vstinnerlinkissue11707 messages
2011-04-05 10:33:55vstinnercreate