diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-02-10 15:43:25 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-02-10 15:43:25 (GMT) |
commit | b8cbba5877df478966092ce069b6cedea8487c53 (patch) | |
tree | de7fcae85c654a604265ef9f73e50c6583ad05b1 /Objects/bytesobject.c | |
parent | 419d9a83d5688940b3dbb410029080ad7f2f71a8 (diff) | |
parent | 801d955f04d46994ac5bc7270fea86a7703c5192 (diff) | |
download | cpython-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.c | 5 |
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) { |