QUERY · ISSUE
Overflow converting -2147483648 to int when using MPZ
py-core
When MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_MPZ, calling mp_obj_get_int() for a Python variable that contains the value -2147483648 results in an overflow converting long int to machine word error.
If MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_LONGLONG instead, the conversion works OK.
Is the MPZ overflow check incorrect?
CANDIDATE · ISSUE
Converting minimum long long value to string results in incorrect output
When mp is configured to use 'long long' ints (MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_LONGLONG), the following code:
print(-0x7fffffffffffffff-1)
results in the string:
-'..--).0-*(+,))+(0(
rather than:
-9223372036854775808
This is due to mp_obj_int_formatted() trying to negate the number, which fails in this case. The subsequent conversion to a string then results in invalid characters due to (I think) signedness issues.