Spurious issue in CPython 2.7.5
Chris Angelico
rosuav at gmail.com
Tue May 24 13:23:03 EDT 2016
On Wed, May 25, 2016 at 3:12 AM, Steven D'Aprano <steve at pearwood.info> wrote:
>> 2: In my process later on I get: "OverflowError: long too big to
>> convert".
>
> Can you copy and paste the actual traceback rather than retyping it from
> memory? I think you're missing something, namely what the long is being
> converted to. The rest of the traceback will help too.
>
>
>> This happens in different places and seems to always relate to
>> obtaining a length of something (dict or list created by list
>> comprehension). Fx
>>
>> "for i in xrange(0, len_of_stuff, max_section_size):"
>>
>> en_of_stuff is always less than the max long (around 600).
>
> What do you mean, "the max long"? Longs do not have a max value. The only
> limit is the amount of memory you have.
A Python long doesn't, but an ssize_t does. In certain places, Python
integers get converted into C integers, at which point an over-large
value triggers OverflowError.
>>> xrange(1<<100)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: Python int too large to convert to C long
>>> xrange(1,500,1<<100)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: Python int too large to convert to C long
(Note: Doesn't happen with a Py3 range object.)
But I echo the request for a copied and pasted error message.
ChrisA
More information about the Python-list
mailing list