summaryrefslogtreecommitdiffstats
path: root/Objects/bytesobject.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-02-10 15:42:01 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2013-02-10 15:42:01 (GMT)
commit801d955f04d46994ac5bc7270fea86a7703c5192 (patch)
treec63cdc08b7a4b1fde457b74143855d2a24fa2da5 /Objects/bytesobject.c
parent6427358501ac5b5a33b1c0543b46f6d378cea7e3 (diff)
parent5e61f14c6dd29982da9364696bc864604b143a66 (diff)
downloadcpython-801d955f04d46994ac5bc7270fea86a7703c5192.zip
cpython-801d955f04d46994ac5bc7270fea86a7703c5192.tar.gz
cpython-801d955f04d46994ac5bc7270fea86a7703c5192.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 5e17107..47898fe 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -465,8 +465,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) {