mirror of https://github.com/python/cpython.git
[3.11] gh-88943: Improve syntax error for non-ASCII character that follows a numerical literal (GH-109081) (GH-109091)
It now points on the invalid non-ASCII character, not on the valid numerical literal.
(cherry picked from commit b2729e93e9
)
This commit is contained in:
parent
d9d64a4a13
commit
dae62d456e
|
@ -238,6 +238,10 @@ def check(test, error=False):
|
|||
check(f"[{num}for x in ()]")
|
||||
check(f"{num}spam", error=True)
|
||||
|
||||
# gh-88943: Invalid non-ASCII character following a numerical literal.
|
||||
with self.assertRaisesRegex(SyntaxError, r"invalid character '⁄' \(U\+2044\)"):
|
||||
compile(f"{num}⁄7", "<testcase>", "eval")
|
||||
|
||||
with warnings.catch_warnings():
|
||||
warnings.filterwarnings('ignore', '"is" with a literal',
|
||||
SyntaxWarning)
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
Improve syntax error for non-ASCII character that follows a numerical
|
||||
literal. It now points on the invalid non-ASCII character, not on the valid
|
||||
numerical literal.
|
|
@ -1303,7 +1303,7 @@ verify_end_of_number(struct tok_state *tok, int c, const char *kind)
|
|||
tok_nextc(tok);
|
||||
}
|
||||
else /* In future releases, only error will remain. */
|
||||
if (is_potential_identifier_char(c)) {
|
||||
if (c < 128 && is_potential_identifier_char(c)) {
|
||||
tok_backup(tok, c);
|
||||
syntaxerror(tok, "invalid %s literal", kind);
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue