summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2021-06-08 00:36:19 (GMT)
committerGitHub <noreply@github.com>2021-06-08 00:36:19 (GMT)
commitd80f4265db63a1692455abb8d1c77d0d72151bbb (patch)
tree1fe4bedf5ad99ac02eec2d8db3cee274f3b51c3a
parent8524e32d77b6741cdd7f947c009b10b54c6529b8 (diff)
downloadcpython-d80f4265db63a1692455abb8d1c77d0d72151bbb.zip
cpython-d80f4265db63a1692455abb8d1c77d0d72151bbb.tar.gz
cpython-d80f4265db63a1692455abb8d1c77d0d72151bbb.tar.bz2
fix: use unambiguous punction in 'invalid escape sequence' message (GH-26582)
(cherry picked from commit ffd87b7093109c279caf8e3ca060f408a102388a) Co-authored-by: Ned Batchelder <ned@nedbatchelder.com>
-rw-r--r--Lib/test/test_cmd_line_script.py2
-rw-r--r--Parser/string_parser.c4
2 files changed, 3 insertions, 3 deletions
diff --git a/Lib/test/test_cmd_line_script.py b/Lib/test/test_cmd_line_script.py
index af29c17..6ffec91 100644
--- a/Lib/test/test_cmd_line_script.py
+++ b/Lib/test/test_cmd_line_script.py
@@ -651,7 +651,7 @@ class CmdLineTest(unittest.TestCase):
stderr.splitlines()[-3:],
[ b' foo = """\\q"""',
b' ^^^^^^^^',
- b'SyntaxError: invalid escape sequence \\q'
+ b'SyntaxError: invalid escape sequence \'\\q\''
],
)
diff --git a/Parser/string_parser.c b/Parser/string_parser.c
index b919633..fa41a36 100644
--- a/Parser/string_parser.c
+++ b/Parser/string_parser.c
@@ -12,7 +12,7 @@ static int
warn_invalid_escape_sequence(Parser *p, unsigned char first_invalid_escape_char, Token *t)
{
PyObject *msg =
- PyUnicode_FromFormat("invalid escape sequence \\%c", first_invalid_escape_char);
+ PyUnicode_FromFormat("invalid escape sequence '\\%c'", first_invalid_escape_char);
if (msg == NULL) {
return -1;
}
@@ -27,7 +27,7 @@ warn_invalid_escape_sequence(Parser *p, unsigned char first_invalid_escape_char,
since _PyPegen_raise_error uses p->tokens[p->fill - 1] for the
error location, if p->known_err_token is not set. */
p->known_err_token = t;
- RAISE_SYNTAX_ERROR("invalid escape sequence \\%c", first_invalid_escape_char);
+ RAISE_SYNTAX_ERROR("invalid escape sequence '\\%c'", first_invalid_escape_char);
}
Py_DECREF(msg);
return -1;