On Thu, 24 Mar 2005 23:21:39 -0000, Grant Edwards <[EMAIL PROTECTED]> wrote:
>How do I get rid of the following warning? > > <path>.py:233: FutureWarning: hex/oct constants > sys.maxint will return > positive values in Python 2.4 and up > fcntl.ioctl(self.dev.fileno(),0xc0047a80,struct.pack("HBB",i,0,0)) > >I tried using 0xc0047a80L. That got rid of the warning, but >then I got an exception when fcntl.ioctl() was called because >the long int was too large to be converted to an int. > Lobby for a PEP for numeric literals allowing representation of negative numbers without writing a unary minus expression. E.g., 16xfc0047a80 would be explicitly negative and would not overflow 32-bit representation. The corresponding positive value 16x0c0047a80 would overflow, of course, which would be proper. Some discussion, including analogous spellings for other bases: http://groups-beta.google.com/group/comp.lang.python/msg/c23131df1e919435 In the meantime, maybe (ugh): Python 2.3.2 (#49, Oct 2 2003, 20:02:00) [MSC v.1200 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> -2*0x40000000+0x40047a80 -1073448320 >>> hex(-2*0x40000000+0x40047a80) __main__:1: FutureWarning: hex()/oct() of negative int will return a signed string in Python 2.4 and up '0xc0047a80' That "signed string" is a unary minus expression using an absolute value forced by the inadequacy of the literal representation syntax. IOW, IMO '-' + hex_literal_of(abs(x)) is not a decent hex_literal_of(-x) !! Urk and argh... Regards, Bengt Richter -- http://mail.python.org/mailman/listinfo/python-list