Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Can't convert -0x80000000 to int32 with mp_obj_int_get_checked #2868

Closed
@ghseb

Description

@ghseb

Hello,

correct me if im wrong, but

mp_int_t in = -0x80000000;
mp_obj_t i = mp_obj_new_int_from_ll(in);
mp_int_t out = mp_obj_int_get_checked(i);

throws

OverflowError: overflow converting long int to machine word

I would expect this conversion to be valid since -0x80000000 is in the range of a int32.

This works:

mp_int_t in = -0x7FFFFFFF;
mp_obj_t i = mp_obj_new_int_from_ll(in);
mp_int_t out = mp_obj_int_get_checked(i);

Sebastian

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions