diff Objects/bytesobject.c @ 82136:305210a08fc9 3.2

Issue #12983: Bytes literals with invalid \x escape now raise a SyntaxError and a full traceback including line number.
author Serhiy Storchaka <storchaka@gmail.com>
date Sun, 10 Feb 2013 17:36:00 +0200
parents 8a747dec89c5
children d5b731446a91
line wrap: on
line diff
--- a/Objects/bytesobject.c	Sun Feb 10 14:16:10 2013 +0000
+++ b/Objects/bytesobject.c	Sun Feb 10 17:36:00 2013 +0200
@@ -469,8 +469,9 @@
                 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) {