diff options
author | Lysandros Nikolaou <lisandrosnik@gmail.com> | 2023-04-24 18:30:21 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-24 18:30:21 (GMT) |
commit | cb157a1a353675cb6f08bdae5d7aadd6b28bb0a9 (patch) | |
tree | b833923555d01ad4cc45e6e89bb2fc710fda5a08 /Lib/test/test_fstring.py | |
parent | ab25c7e3112b24a4cd8cb626bbd924c57af0fe1c (diff) | |
download | cpython-cb157a1a353675cb6f08bdae5d7aadd6b28bb0a9.zip cpython-cb157a1a353675cb6f08bdae5d7aadd6b28bb0a9.tar.gz cpython-cb157a1a353675cb6f08bdae5d7aadd6b28bb0a9.tar.bz2 |
GH-103727: Avoid advancing tokenizer too far in f-string mode (GH-103775)
Diffstat (limited to 'Lib/test/test_fstring.py')
-rw-r--r-- | Lib/test/test_fstring.py | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/Lib/test/test_fstring.py b/Lib/test/test_fstring.py index b26b12d..9d5e166 100644 --- a/Lib/test/test_fstring.py +++ b/Lib/test/test_fstring.py @@ -940,15 +940,13 @@ x = ( "f'{lambda :x}'", "f'{lambda *arg, :x}'", "f'{1, lambda:x}'", + "f'{lambda x:}'", + "f'{lambda :}'", ]) # but don't emit the paren warning in general cases - self.assertAllRaise(SyntaxError, - "f-string: expecting a valid expression after '{'", - ["f'{lambda x:}'", - "f'{lambda :}'", - "f'{+ lambda:None}'", - ]) + with self.assertRaisesRegex(SyntaxError, "f-string: expecting a valid expression after '{'"): + eval("f'{+ lambda:None}'") def test_valid_prefixes(self): self.assertEqual(F'{1}', "1") |