Don't be so hasty. If PyInt_AsLong() raises an error, don't set ValueError.

This commit is contained in:
Jeremy Hylton 2002-07-25 16:43:29 +00:00
parent 825e47b655
commit 73a088e3fa
1 changed files with 2 additions and 0 deletions

View File

@ -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");