summaryrefslogtreecommitdiff
path: root/Objects/bytesobject.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-02-10 17:43:25 +0200
committerSerhiy Storchaka <storchaka@gmail.com>2013-02-10 17:43:25 +0200
commitb8cbba5877df478966092ce069b6cedea8487c53 (patch)
treede7fcae85c654a604265ef9f73e50c6583ad05b1 /Objects/bytesobject.c
parent419d9a83d5688940b3dbb410029080ad7f2f71a8 (diff)
parent801d955f04d46994ac5bc7270fea86a7703c5192 (diff)
downloadcpython-git-b8cbba5877df478966092ce069b6cedea8487c53.tar.gz
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 ba1fefd897..056ac3689f 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) {