Fix possible overflow in wrap_lenfunc() when
sizeof(long) < sizeof(Py_ssize_t) (e.g., 64-bit Windows).
a.setstate(100)
self.assertEqual(a.getstate(), 100)
+ def test_wrap_lenfunc_bad_cast(self):
+ self.assertEqual(range(sys.maxsize).__len__(), sys.maxsize)
+
+
class ClassPropertiesAndMethods(unittest.TestCase):
def assertHasAttr(self, obj, name):
--- /dev/null
+Fix possible overflow in ``wrap_lenfunc()`` when
+``sizeof(long) < sizeof(Py_ssize_t)`` (e.g., 64-bit Windows).
res = (*func)(self);
if (res == -1 && PyErr_Occurred())
return NULL;
- return PyLong_FromLong((long)res);
+ return PyLong_FromSsize_t(res);
}
static PyObject *