[Python-3000] Using range()

Mark Dickinson dickinsm at gmail.com
Thu Apr 24 17:42:56 CEST 2008


On Thu, Apr 24, 2008 at 11:37 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:

> While I could understand a 'must fit in ssize_t' limitation on the index
> passed to the range object (or conceivably even on the value returned,
> although that would be a little odd), that isn't happening in the example -
> the index being passed in is zero, and the value that should be getting
> returned is zero. Where is that OverflowError coming from? Is there a
> missing PyErr_Clear() call in the range code somewhere? Should the range
> code be invoking a different PyNumber_ call when it does the conversion?
>

Looks like it's coming from range_length, which gets called from
range_item, which implements the sq_item slot.  range_item
uses the length to check the validity of the given index.

I don't think it would be difficult to fix this so that indices
up to the max value of a Py_ssize_t are valid.

I agree it's worth opening a tracker issue for.

Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-3000/attachments/20080424/eabd070d/attachment.htm>


More information about the Python-3000 mailing list