fix len() when __len__() returns a non number type #5137

This commit is contained in:
Benjamin Peterson 2009-02-08 21:07:20 +00:00
parent c7055a59a6
commit ee1ae7ccb7
3 changed files with 16 additions and 1 deletions

View file

@ -4618,7 +4618,7 @@ slot_sq_length(PyObject *self)
if (res == NULL)
return -1;
len = PyLong_AsSsize_t(res);
len = PyNumber_AsSsize_t(res, PyExc_OverflowError);
Py_DECREF(res);
if (len < 0) {
if (!PyErr_Occurred())