summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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;
}