diff options
Diffstat (limited to 'Objects/rangeobject.c')
-rw-r--r-- | Objects/rangeobject.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c index 3080252..6c9daad 100644 --- a/Objects/rangeobject.c +++ b/Objects/rangeobject.c @@ -130,7 +130,14 @@ range_item(rangeobject *r, int i) static int range_length(rangeobject *r) { - return r->len; +#if LONG_MAX != INT_MAX + if (r->len > INT_MAX) { + PyErr_SetString(PyExc_ValueError, + "xrange object size cannot be reported"); + return -1; + } +#endif + return (int)(r->len); } static PyObject * |