summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-02-10 15:36:00 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2013-02-10 15:36:00 (GMT)
commit5e61f14c6dd29982da9364696bc864604b143a66 (patch)
tree7af9b9389674a1d50caa01a9154bc919697bd6d5 /Objects
parentbe5f91957f3d553a7cbbfdc43f66a3b30bb97aec (diff)
downloadcpython-5e61f14c6dd29982da9364696bc864604b143a66.zip
cpython-5e61f14c6dd29982da9364696bc864604b143a66.tar.gz
cpython-5e61f14c6dd29982da9364696bc864604b143a66.tar.bz2
Issue #12983: Bytes literals with invalid \x escape now raise a SyntaxError
and a full traceback including line number.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/bytesobject.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index b60a8b0..cb5679b 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -469,8 +469,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) {