LongInt-to-String % Bug (was Re: Python plugin)

Randall Hopper aa8vb at yahoo.com
Tue Jan 11 10:49:27 EST 2000


Samuel A. Falvo II:
 |To be fair, Python isn't without its numerical faults either.  For example:
 |
 |>>> data = string.atol( stringArgument[0:8] )
 |>>> print "%08lX" % (data)
 |
 |will fault on any integral value greater than 0x7FFFFFFF.  Why?  Because
 |Python just plain can't understand the concept of an unsigned integer.

That's odd, especially considering str() and hex() can cut the mustard.

I don't see a bug report in the database for this; you might want to file one:

     http://www.python.org/search/search_bugs.html


    >>> str( 0x80000000L )
    '2147483648L'
    >>> "%ld" % 0x80000000L
    OverflowError: long int too long to convert

    >>> hex( 0x80000000L )
    '0x80000000L'
    >>> "%lX" % 0x80000000L
    OverflowError: long int too long to convert


LibCh2:
"The size specifiers h, l , or L may be present but are ignored"
No caveats about long ints though.

-- 
Randall Hopper
aa8vb at yahoo.com




More information about the Python-list mailing list