mirror of
https://github.com/python/cpython.git
synced 2025-12-23 09:19:18 +00:00
bpo-45811: Improve error message when source code contains invisible control characters (GH-29654)
This commit is contained in:
parent
7a1d932528
commit
81f4e116ef
3 changed files with 11 additions and 0 deletions
|
|
@ -2045,6 +2045,12 @@ tok_get(struct tok_state *tok, const char **p_start, const char **p_end)
|
|||
break;
|
||||
}
|
||||
|
||||
if (!Py_UNICODE_ISPRINTABLE(c)) {
|
||||
char hex[9];
|
||||
(void)PyOS_snprintf(hex, sizeof(hex), "%04X", c);
|
||||
return syntaxerror(tok, "invalid non-printable character U+%s", hex);
|
||||
}
|
||||
|
||||
/* Punctuation character */
|
||||
*p_start = tok->start;
|
||||
*p_end = tok->cur;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue