mirror of https://github.com/python/cpython
fix: use unambiguous punction in 'invalid escape sequence' message (GH-26582)
This commit is contained in:
parent
165c884154
commit
ffd87b7093
|
@ -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\''
|
||||
],
|
||||
)
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue