summaryrefslogtreecommitdiffstats
path: root/Objects/bytesobject.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-02-10 15:43:25 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2013-02-10 15:43:25 (GMT)
commitb8cbba5877df478966092ce069b6cedea8487c53 (patch)
treede7fcae85c654a604265ef9f73e50c6583ad05b1 /Objects/bytesobject.c
parent419d9a83d5688940b3dbb410029080ad7f2f71a8 (diff)
parent801d955f04d46994ac5bc7270fea86a7703c5192 (diff)
downloadcpython-b8cbba5877df478966092ce069b6cedea8487c53.zip
cpython-b8cbba5877df478966092ce069b6cedea8487c53.tar.gz
cpython-b8cbba5877df478966092ce069b6cedea8487c53.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/bytesobject.c')
-rw-r--r--Objects/bytesobject.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index ba1fefd..056ac36 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -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) {