◐ Shell
clean mode source ↗

Message 72151 - Python tracker

Not bad! some remarks though:
- It's better to avoid the "expensive" call to PyErr_Occurred() when
possible. Here, an exception is set if (and only if) len==-1.
For example, it is enough to add these lines after the "__len__() should
return >= 0" message:

+		else if (PyErr_ExceptionMatches(PyExc_TypeError))
+			PyErr_SetString(PyExc_TypeError, 
+					"__len__() should return an int");

- Please clarify (that is: add tests for) the case where __len__ returns
1<<50 or -1<<50. If I remember correctly, PyNumber_AsSsize_t(res, NULL)
clips the values to MAXINT. Is this wanted?