hex/oct constants > sys.maxint will return positive values in Python 2.4 and up

Jon Ribbens jon+usenet at unequivocal.co.uk
Wed Nov 6 16:40:51 EST 2002


In article <mailman.1036612151.5855.python-list at python.org>, Tim Peters wrote:
>> What am I supposed to do to make the warning go away? Rewrite 0x80000000
>> as 0x40000000 * 2 ? ;-)
> 
> Write it in a platform-independent way.  If you *intended* this literal to
> mean "a 1 bit followed by 31 zero bits", then stick an L on the end of the
> literal.

That'll generate a warning when we get to stage B2 of PEP237 and an
error by stage B4 so that makes things worse... (not much worse since
B4 is so far off, but still...)

I don't really like the idea of hacking around with the warning
module, so I guess I'll replace 0x80000000 with (-0x7fffffff-1) which
won't generate a warning on any version of Python and will work on all
versions... I think ;-)



More information about the Python-list mailing list