summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2002-07-25 16:06:15 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2002-07-25 16:06:15 (GMT)
commitf20fcf9fedfbd4d69e4197c78f0b652c4938f761 (patch)
treedaffabc9665fe9db715d538b24ba0bafc9345078
parentc075e197d6453939bce6253ebb4fdb5dffaeb6c7 (diff)
downloadcpython-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.c5
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;
}