mirror of
https://github.com/python/cpython.git
synced 2025-07-23 19:25:40 +00:00
Complain if __len__() returns < 0, just like classic classes.
Fixes SF bug #575773. Bug fix candidate.
This commit is contained in:
parent
c075e197d6
commit
f20fcf9fed
1 changed files with 5 additions and 0 deletions
|
@ -2972,6 +2972,11 @@ slot_sq_length(PyObject *self)
|
||||||
return -1;
|
return -1;
|
||||||
len = (int)PyInt_AsLong(res);
|
len = (int)PyInt_AsLong(res);
|
||||||
Py_DECREF(res);
|
Py_DECREF(res);
|
||||||
|
if (len < 0) {
|
||||||
|
PyErr_SetString(PyExc_ValueError,
|
||||||
|
"__len__() should return >= 0");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue