classification
Title: byte string literals with invalid hex escape codes raise ValueError instead of SyntaxError
Type: behavior Stage: test needed
Components: Interpreter Core Versions: Python 3.3, Python 3.2
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: abacabadabacaba, ezio.melotti, ned.deily
Priority: normal Keywords:

Created on 2011-09-14 22:51 by ned.deily, last changed 2011-09-15 14:22 by abacabadabacaba.

Messages (1)
msg144059 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2011-09-14 22:51
In behavior carried over from Python 2 string literals, Python 3 byte string literals raise a less helpful ValueError exception when an invalid hex escape code is given:

    >>> x = b'\x0'
    ValueError: invalid \x escape

A string literal raises a SyntaxError and a full traceback including line number:

    >>> x = '\x0'
      File "<stdin>", line 1
    SyntaxError: (unicode error) 'unicodeescape' codec can't decode
     bytes in position 0-2: end of string in escape sequence
History
Date User Action Args
2011-09-15 14:22:56abacabadabacabasetnosy: + abacabadabacaba
2011-09-15 03:17:26ezio.melottisetnosy: + ezio.melotti

stage: test needed
2011-09-14 22:51:36ned.deilycreate