Kaydet (Commit) f20fcf9f authored tarafından Jeremy Hylton's avatar Jeremy Hylton

Complain if __len__() returns < 0, just like classic classes.

Fixes SF bug #575773.

Bug fix candidate.
üst c075e197
...@@ -2972,6 +2972,11 @@ slot_sq_length(PyObject *self) ...@@ -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;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment