From 5e61f14c6dd29982da9364696bc864604b143a66 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sun, 10 Feb 2013 17:36:00 +0200 Subject: Issue #12983: Bytes literals with invalid \x escape now raise a SyntaxError and a full traceback including line number. --- Objects/bytesobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Objects') diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c index b60a8b06c3..cb5679bc38 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) { -- cgit v1.2.1