diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2006-02-15 17:27:45 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2006-02-15 17:27:45 (GMT) |
commit | 18e165558b24d29e7e0ca501842b9236589b012a (patch) | |
tree | 841678b5dc1aff3aa48701fee33a6ba7be00a72b /Objects/rangeobject.c | |
parent | 44829297348d9121a03fc7df2fac557b583cc7fa (diff) | |
download | cpython-18e165558b24d29e7e0ca501842b9236589b012a.zip cpython-18e165558b24d29e7e0ca501842b9236589b012a.tar.gz cpython-18e165558b24d29e7e0ca501842b9236589b012a.tar.bz2 |
Merge ssize_t branch.
Diffstat (limited to 'Objects/rangeobject.c')
-rw-r--r-- | Objects/rangeobject.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c index cfd9100..a9c0b55 100644 --- a/Objects/rangeobject.c +++ b/Objects/rangeobject.c @@ -91,27 +91,27 @@ generates the numbers in the range on demand. For looping, this is \n\ slightly faster than range() and more memory efficient."); static PyObject * -range_item(rangeobject *r, int i) +range_item(rangeobject *r, Py_ssize_t i) { if (i < 0 || i >= r->len) { PyErr_SetString(PyExc_IndexError, "xrange object index out of range"); return NULL; } - return PyInt_FromLong(r->start + (i % r->len) * r->step); + return PyInt_FromSsize_t(r->start + (i % r->len) * r->step); } -static int +static Py_ssize_t range_length(rangeobject *r) { -#if LONG_MAX != INT_MAX +#if LONG_MAX != INT_MAX /* XXX ssize_t_max */ if (r->len > INT_MAX) { PyErr_SetString(PyExc_ValueError, "xrange object size cannot be reported"); return -1; } #endif - return (int)(r->len); + return (Py_ssize_t)(r->len); } static PyObject * @@ -137,10 +137,10 @@ range_repr(rangeobject *r) } static PySequenceMethods range_as_sequence = { - (inquiry)range_length, /* sq_length */ + (lenfunc)range_length, /* sq_length */ 0, /* sq_concat */ 0, /* sq_repeat */ - (intargfunc)range_item, /* sq_item */ + (ssizeargfunc)range_item, /* sq_item */ 0, /* sq_slice */ }; |