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