Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OverflowError: Python int too large to convert to C long #66015

Closed
ThomasBall mannequin opened this issue Jun 20, 2014 · 2 comments
Closed

OverflowError: Python int too large to convert to C long #66015

ThomasBall mannequin opened this issue Jun 20, 2014 · 2 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@ThomasBall
Copy link
Mannequin

ThomasBall mannequin commented Jun 20, 2014

BPO 21816
Nosy @ned-deily
Files
  • testint.py: Python repo
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2014-06-20.20:21:51.127>
    created_at = <Date 2014-06-20.19:18:11.347>
    labels = ['type-bug', 'invalid']
    title = 'OverflowError: Python int too large to convert to C long'
    updated_at = <Date 2014-06-20.20:21:51.125>
    user = 'https://bugs.python.org/ThomasBall'

    bugs.python.org fields:

    activity = <Date 2014-06-20.20:21:51.125>
    actor = 'ned.deily'
    assignee = 'none'
    closed = True
    closed_date = <Date 2014-06-20.20:21:51.127>
    closer = 'ned.deily'
    components = []
    creation = <Date 2014-06-20.19:18:11.347>
    creator = 'Thomas.Ball'
    dependencies = []
    files = ['35712']
    hgrepos = []
    issue_num = 21816
    keywords = []
    message_count = 2.0
    messages = ['221116', '221121']
    nosy_count = 2.0
    nosy_names = ['ned.deily', 'Thomas.Ball']
    pr_nums = []
    priority = 'normal'
    resolution = 'not a bug'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue21816'
    versions = ['Python 2.7']

    @ThomasBall
    Copy link
    Mannequin Author

    ThomasBall mannequin commented Jun 20, 2014

    The attached file raises the exception:

    OverflowError: Python int too large to convert to C long

    in Python 2.7.7, which clearly is a bug.

    The error is not present in Python 3.4.

    @ThomasBall ThomasBall mannequin added the type-bug An unexpected behavior, bug, or error label Jun 20, 2014
    @ned-deily
    Copy link
    Member

    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

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant