mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Don't be so hasty. If PyInt_AsLong() raises an error, don't set ValueError.
This commit is contained in:
parent
825e47b655
commit
73a088e3fa
1 changed files with 2 additions and 0 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue