Don't be so hasty. If PyInt_AsLong() raises an error, don't set ValueError.
This commit is contained in:
parent
825e47b655
commit
73a088e3fa
|
@ -2972,6 +2972,8 @@ slot_sq_length(PyObject *self)
|
|||
return -1;
|
||||
len = (int)PyInt_AsLong(res);
|
||||
Py_DECREF(res);
|
||||
if (len == -1 && PyErr_Occurred())
|
||||
return -1;
|
||||
if (len < 0) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"__len__() should return >= 0");
|
||||
|
|
Loading…
Reference in New Issue