hex/oct constants > sys.maxint will return positive values in Python 2.4 and up
Tim Peters
tim.one at comcast.net
Wed Nov 6 14:47:07 EST 2002
[Jon Ribbens]
> My jonpy modules are producing the following warning when compiled
> under Python 2.3 (current cvs):
>
> FutureWarning: hex/oct constants > sys.maxint will return positive
> values in Python 2.4 and up
>
> The offending line of code is as follows:
>
> data = struct.pack("!I", len(nameval[0]) | 0x80000000)
>
> As far as I can tell, this change, when it comes in, will make no
> difference at all to the way this code works. Am I right?
Probably, because the ultimate consumer of the computed value is a pack
format using a platform-independent definition of "I". Without the leading
"!" in the format, though, you get a platform-dependent pack, and 0x80000000
doesn't mean the same thing across all platforms today (but will starting in
Python 2.4).
> 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.
More information about the Python-list
mailing list