mirror of
https://github.com/python/cpython.git
synced 2025-11-01 02:38:53 +00:00
gh-88943: Improve syntax error for non-ASCII character that follows a numerical literal (GH-109081)
It now points on the invalid non-ASCII character, not on the valid numerical literal.
This commit is contained in:
parent
ac31f714c3
commit
b2729e93e9
3 changed files with 8 additions and 1 deletions
|
|
@ -236,6 +236,10 @@ class TokenTests(unittest.TestCase):
|
|||
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 self.assertWarnsRegex(SyntaxWarning, r'invalid \w+ literal'):
|
||||
compile(f"{num}is x", "<testcase>", "eval")
|
||||
with warnings.catch_warnings():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue