Is this a bug in int()?

George Sakkis george.sakkis at gmail.com
Sat Dec 22 19:57:44 EST 2007


On Dec 22, 5:03 pm, MartinRineh... at gmail.com wrote:

> Tokenizer accepts "0x" as zero. Spec says its an error not to have at
> least one hex digit after "0x".
>
> This is a more serious bug than I had originally thought. Consider
> this:
>
> Joe types "security_code = 0x" and then goes off to the Guardian-of-
> the-Codes to get the appropriate hex string. Returning to computer,
> Joe's boss grabs him. Tells him that effective immediately he's on the
> "rescue us from this crisis" team; his other project can wait.
>
> Some hours, days or weeks later Joe returns to the first project. At
> this point Joe has a line of code that says "security_code = 0x". I
> think Joe would be well-served by a compiler error on that line. As is
> now, Joe's program assigns 0 to security_code and compiles without
> complaint. I'm pretty sure any line of the form "name = 0x" was a
> product of some form of programmer interruptus.

:-) Are you a fiction writer by any chance ? Nice story but I somehow
doubt that the number of lines of the form "name = 0x" ever written in
Python is greater than a single digit (with zero the most likely one).

George



More information about the Python-list mailing list