diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2023-09-07 14:00:13 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-07 14:00:13 (GMT) |
commit | b2729e93e9d73503b1fda4ea4fecd77c58909091 (patch) | |
tree | 1dbd2482d926c33423c48fde3a2e3505cbb5c5a6 /Lib/test/test_grammar.py | |
parent | ac31f714c3e55a7951a9f3f9c823740c20c5d595 (diff) | |
download | cpython-b2729e93e9d73503b1fda4ea4fecd77c58909091.zip cpython-b2729e93e9d73503b1fda4ea4fecd77c58909091.tar.gz cpython-b2729e93e9d73503b1fda4ea4fecd77c58909091.tar.bz2 |
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.
Diffstat (limited to 'Lib/test/test_grammar.py')
-rw-r--r-- | Lib/test/test_grammar.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py index 7c15a23..8501006 100644 --- a/Lib/test/test_grammar.py +++ b/Lib/test/test_grammar.py @@ -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(): |