[Python-Dev] Go \x yourself
Guido van Rossum
guido@beopen.com
Fri, 04 Aug 2000 10:11:03 -0500
> I'm quite certain that this should be a SyntaxError, not a ValueError:
>
> >>> "\x1"
> SyntaxError: two hex digits are required after \x
> >>> "\x\x"
> SyntaxError: two hex digits are required after \x
>
> Otherwise, +1. Sounds great.
No, problems with literal interpretations traditionally raise
"runtime" exceptions rather than syntax errors. E.g.
>>> 111111111111111111111111111111111111
OverflowError: integer literal too large
>>> u'\u123'
UnicodeError: Unicode-Escape decoding error: truncated \uXXXX
>>>
Note that UnicodeError is a subclass of ValueError.
--Guido van Rossum (home page: http://www.pythonlabs.com/~guido/)