Is this a bug in int()?

Terry Reedy tjreedy at udel.edu
Thu Dec 20 22:11:53 EST 2007


"Duncan Booth" <duncan.booth at invalid.invalid> wrote in message 
news:Xns9A0CDF36C1369duncanbooth at 127.0.0.1...
| MartinRinehart at gmail.com wrote under the subject line "Is this a
| bug in int()?":
| >>>>int('0x', 16)
| > 0
| >
| I think it is a general problem in the tokenizer, not just the 'int'
| constructor. The syntax for integers says:
|
|   hexinteger ::= "0" ("x" | "X") hexdigit+
|
| but 0x appears to be accepted in source code as an integer.
|
| If I were you, I'd try reporting it as a bug.

The mismatch between doc and behavior certainly is a bug.
One should change. 






More information about the Python-list mailing list