diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2002-07-25 16:06:15 (GMT) |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2002-07-25 16:06:15 (GMT) |
commit | f20fcf9fedfbd4d69e4197c78f0b652c4938f761 (patch) | |
tree | daffabc9665fe9db715d538b24ba0bafc9345078 | |
parent | c075e197d6453939bce6253ebb4fdb5dffaeb6c7 (diff) | |
download | cpython-f20fcf9fedfbd4d69e4197c78f0b652c4938f761.zip cpython-f20fcf9fedfbd4d69e4197c78f0b652c4938f761.tar.gz cpython-f20fcf9fedfbd4d69e4197c78f0b652c4938f761.tar.bz2 |
Complain if __len__() returns < 0, just like classic classes.
Fixes SF bug #575773.
Bug fix candidate.
-rw-r--r-- | Objects/typeobject.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 9662d95..96fc7cd 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -2972,6 +2972,11 @@ slot_sq_length(PyObject *self) return -1; len = (int)PyInt_AsLong(res); Py_DECREF(res); + if (len < 0) { + PyErr_SetString(PyExc_ValueError, + "__len__() should return >= 0"); + return -1; + } return len; } |