[Python-Dev] Go \x yourself (original) (raw)
M.-A. Lemburg mal@lemburg.com
Fri, 04 Aug 2000 12:03:49 +0200
- Previous message: [Python-Dev] Go \x yourself
- Next message: [Python-Dev] Go \x yourself
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
[Wow, 5:26 in the morning and still (or already) up and running...]
Tim Peters wrote:
[Tim Peters] > >>> "\x123465" # \x12 -> \022, "3456" left alone > '\0223456' > >>> "\x65" > 'e' > >>> "\x1" > ValueError > >>> "\x\x" > ValueError > >>> [?!ng] > 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. SyntaxError was my original pick too. Guido picked ValueError instead because the corresponding "not enough hex digits" error in Unicode strings for damaged \u1234 escapes raises UnicodeError today, which is a subclass of ValueError. I couldn't care less, and remain +1 either way. On the chance that the BDFL may have changed his mind, I've copied him on this msg, This is your one & only chance to prevail .
The reason for Unicode raising a UnicodeError is that the string is passed through a codec in order to be converted to Unicode. Codecs raise ValueErrors for encoding errors.
The "\x..." errors should probably be handled in the same way to assure forward compatibility (they might be passed through codecs as well in some future Python version in order to implement source code encodings).
-- Marc-Andre Lemburg
Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/
- Previous message: [Python-Dev] Go \x yourself
- Next message: [Python-Dev] Go \x yourself
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]