commit | f20fcf9fedfbd4d69e4197c78f0b652c4938f761 | [log] [tgz] |
---|---|---|
author | Jeremy Hylton <jeremy@alum.mit.edu> | Thu Jul 25 16:06:15 2002 +0000 |
committer | Jeremy Hylton <jeremy@alum.mit.edu> | Thu Jul 25 16:06:15 2002 +0000 |
tree | daffabc9665fe9db715d538b24ba0bafc9345078 | |
parent | c075e197d6453939bce6253ebb4fdb5dffaeb6c7 [diff] |
Complain if __len__() returns < 0, just like classic classes. Fixes SF bug #575773. Bug fix candidate.
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 @@ 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; }