Issue 12983: byte string literals with invalid hex escape codes raise ValueError instead of SyntaxError (original ) (raw ) Issue12983
Created on 2011-09-14 22:51 by ned.deily , last changed 2022-04-11 14:57 by admin . This issue is now closed .
Messages (5)
msg144059 - (view)
Author: Ned Deily (ned.deily) *
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 "", line 1 SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 0-2: end of string in escape sequence
msg180054 - (view)
Author: Serhiy Storchaka (serhiy.storchaka) *
Date: 2013-01-15 21:37
Here is a patch which include position number in the invalid bytes exception, wrap it into SyntaxError, and adds tests for bytes and strings.
msg181431 - (view)
Author: Serhiy Storchaka (serhiy.storchaka) *
Date: 2013-02-05 12:56
Ping.
msg181812 - (view)
Author: Benjamin Peterson (benjamin.peterson) *
Date: 2013-02-10 15:18
LGTM
msg181815 - (view)
Author: Roundup Robot (python-dev)
Date: 2013-02-10 15:45
New changeset 305210a08fc9 by Serhiy Storchaka in branch '3.2': Issue #12983 : Bytes literals with invalid \x escape now raise a SyntaxError http://hg.python.org/cpython/rev/305210a08fc9 New changeset d5b731446a91 by Serhiy Storchaka in branch '3.3': Issue #12983 : Bytes literals with invalid \x escape now raise a SyntaxError http://hg.python.org/cpython/rev/d5b731446a91 New changeset fe410292cba6 by Serhiy Storchaka in branch 'default': Issue #12983 : Bytes literals with invalid \x escape now raise a SyntaxError http://hg.python.org/cpython/rev/fe410292cba6
History
Date
User
Action
Args
2022-04-11 14:57:21
admin
set
github: 57192
2013-02-10 17:19:11
serhiy.storchaka
set
status: open -> closedresolution: fixedstage: patch review -> resolved
2013-02-10 15:45:32
python-dev
set
nosy: + python-dev messages: +
2013-02-10 15🔞40
benjamin.peterson
set
messages: +
2013-02-09 21:08:26
serhiy.storchaka
set
nosy: + benjamin.peterson
2013-02-05 12:56:18
serhiy.storchaka
set
messages: +
2013-01-31 14:28:36
serhiy.storchaka
set
assignee: serhiy.storchaka
2013-01-15 21:37:19
serhiy.storchaka
set
files: + parse_strlit_error.patch versions: + Python 3.4keywords: + patch nosy: + serhiy.storchaka messages: + stage: test needed -> patch review
2011-09-15 14:22:56
abacabadabacaba
set
nosy: + abacabadabacaba
2011-09-15 03:17:26
ezio.melotti
set
nosy: + ezio.melotti stage: test needed
2011-09-14 22:51:36
ned.deily
create