diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2002-07-25 16:43:29 (GMT) |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2002-07-25 16:43:29 (GMT) |
commit | 73a088e3fafbfc8b925163a3b0aa626830d26aa0 (patch) | |
tree | afc0cc41574fd1d5a9a33c6487ce6c906669cbba | |
parent | 825e47b655623dff7ca515b28fe5d7b0ecfe7ad1 (diff) | |
download | cpython-73a088e3fafbfc8b925163a3b0aa626830d26aa0.zip cpython-73a088e3fafbfc8b925163a3b0aa626830d26aa0.tar.gz cpython-73a088e3fafbfc8b925163a3b0aa626830d26aa0.tar.bz2 |
Don't be so hasty. If PyInt_AsLong() raises an error, don't set ValueError.
-rw-r--r-- | Objects/typeobject.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 96fc7cd..3def134 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -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"); |