Issue #12983: Bytes literals with invalid \x escape now raise a SyntaxError

and a full traceback including line number.
This commit is contained in:
Serhiy Storchaka 2013-02-10 17:43:25 +02:00
commit b8cbba5877
4 changed files with 51 additions and 9 deletions

View file

@ -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) {