mirror of
https://github.com/python/cpython.git
synced 2025-08-02 16:13:13 +00:00
Issue #12983: Bytes literals with invalid \x escape now raise a SyntaxError
and a full traceback including line number.
This commit is contained in:
commit
b8cbba5877
4 changed files with 51 additions and 9 deletions
|
@ -474,8 +474,9 @@ PyObject *PyBytes_DecodeEscape(const char *s,
|
|||
break;
|
||||
}
|
||||
if (!errors || strcmp(errors, "strict") == 0) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"invalid \\x escape");
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"invalid \\x escape at position %d",
|
||||
s - 2 - (end - len));
|
||||
goto failed;
|
||||
}
|
||||
if (strcmp(errors, "replace") == 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue