Re: Is this a bug in int()?

2007-12-22 Thread Steven D'Aprano
On Sat, 22 Dec 2007 14:03:09 -0800, MartinRinehart 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

Re: Is this a bug in int()?

2007-12-22 Thread George Sakkis
On Dec 22, 5:03 pm, [EMAIL PROTECTED] 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

Re: Is this a bug in int()?

2007-12-22 Thread MartinRinehart
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. Returnin

Re: Is this a bug in int()?

2007-12-21 Thread MartinRinehart
Tokenizer bug reported. [EMAIL PROTECTED] wrote: > >>>int('0x', 16) > 0 > > I'm working on a tokenizer and I'm thinking about returning a > MALFORMED_NUMBER token (1.2E, .5E+) -- http://mail.python.org/mailman/listinfo/python-list

Re: Is this a bug in int()?

2007-12-21 Thread MartinRinehart
Duncan Booth wrote: > Why would you return a token rather than throwing an exception? Tokenizers have lots of uses. Colorizing text in an editor, for example. We've got a MALFORMED_NUMBER when you type '0x'. We've got an INTEGER when we get your next keystroke (probably). -- http://mail.python.

Re: Is this a bug in int()?

2007-12-20 Thread Terry Reedy
"Duncan Booth" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | [EMAIL PROTECTED] 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

Re: Is this a bug in int()?

2007-12-20 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: int('0x', 16) > 0 > > I'm working on a tokenizer and I'm thinking about returning a > MALFORMED_NUMBER token (1.2E, .5E+) Somewhat surprisingly, "0x" is a valid integer literal in Python: >>> 0x 0 -- http://mail.python.org/mailman/listinfo/python-list

Re: Is this a bug in int()?

2007-12-20 Thread Duncan Booth
[EMAIL PROTECTED] 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"

Is this a bug in int()?

2007-12-20 Thread MartinRinehart
>>>int('0x', 16) 0 I'm working on a tokenizer and I'm thinking about returning a MALFORMED_NUMBER token (1.2E, .5E+) -- http://mail.python.org/mailman/listinfo/python-list