int(long(-sys.maxint-1)) fails on Linux

Tim Peters tim_one at email.msn.com
Thu Jul 22 20:10:19 EDT 1999


[Chad Netzer]
> Compiling python 1.5.2 on Linux Mandrake 6.0,  the "make test" step fails
> because it gets an OverflowError during test_types.py on the
> following line:
>
> int(long(-sys.maxint-1))
>
> test_long.py fails also for the same reason.

Chad, let's break this down to see where the overflow is coming from.  Try
this line by line and post your results:

>>> import sys
>>> sys.maxint
2147483647
>>> -sys.maxint
-2147483647
>>> -sys.maxint-1
-2147483648
>>> long(-sys.maxint-1)
-2147483648L
>>> int(long(-sys.maxint-1))
-2147483648
>>>

Neither the OS nor the libraries should have anything to do with this.  You
didn't mention the important part, though <wink>:  what kind of HW is this
running on?  If it has a "funny" wordsize, and limits.h is missing or
foolish, Python may have a bogus idea of what the largest int is (which is
why I want to see what sys.maxint returns for you).

boy-that-linux-is-unstable<wink>-ly y'rs  - tim






More information about the Python-list mailing list