Overflow converting -2147483648 to int when using MPZ
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?
py: Convert float to correct int type
A redo of pull request #1047, to address issue #1042 (currently worked around by ad2307c92c15f0aa90dbd0741fd2538719d0b5e1).
The approach I used in the end allowed for the full range of small ints to be used. Exceptions are now raised in the event of an overflow as well.
As discussed, fpclassify() is used to test for inf and NaN, and the new mp_classify_fp_as_int() function is used for all other values.
The code size could be reduced slightly by not caring so much about ensuring that the full range of small ints are used, but (in the case of MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_MPZ), this would also result in exceptions being raised when the number could be converted to an int (which I would count as a bug).