[issue21816] OverflowError: Python int too large to convert to C long

Ned Deily report at bugs.python.org
Fri Jun 20 22:21:51 CEST 2014


Ned Deily added the comment:

In a 32-bit version of Python 2, that value cannot be represented as an 'int' type.

>>> i = 3783907807
>>> type(i)
<type 'long'>

Normally, Python 2 implicitly creates objects of type 'int' or type 'long' as needed.  But in your example, you are forcing type 'int' and you correctly get an exception.  Your example does not fail with a 64-bit version of Python 2 but it would fail with a larger number.  Python 3 does not have this problem because the distinction between the two types has been removed: all Python 3 ints are unlimited precision.

https://docs.python.org/2/library/stdtypes.html#numeric-types-int-float-long-complex
https://docs.python.org/3.4/whatsnew/3.0.html#integers

----------
nosy: +ned.deily
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21816>
_______________________________________


More information about the Python-bugs-list mailing list