2.3 -> 2.4: long int too large to convert to int
Terry Reedy
tjreedy at udel.edu
Thu Sep 15 18:39:42 EDT 2005
"Grant Edwards" <grante at visi.com> wrote in message
news:11ijsh0h2dec0ed at corp.supernews.com...
>I give up, how do I make this not fail under 2.4?
>
>
> fcntl.ioctl(self.dev.fileno(),0xc0047a80,struct.pack("HBB",0x1c,0x00,0x00))
>
> I get an OverflowError: long int too large to convert to int
>
> ioctl() is expecting a 32-bit integer value, and 0xc0047a80 has
> the high-order bit set. I'm assuming Python thinks it's a
> signed value. How do I tell Python that 0xc0047a80 is an
> unsigned 32-bit value?
In 2.3 and before, you get this:
>>> 0xc0047a80
-1073448320
In 2.4, positive hex literals are treated as positive numbers, and that is
your problem: your literal is greater than the largest int and hence gets
stored as long int. I would try -1073448320 as the arg.
Terry J. Reedy
More information about the Python-list
mailing list