STINNER Victor <victor.stin...@haypocalc.com> added the comment:

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;
    }

----------
nosy: +haypo

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue11707>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to