mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
GH-103727: Avoid advancing tokenizer too far in f-string mode (GH-103775)
This commit is contained in:
parent
ab25c7e311
commit
cb157a1a35
2 changed files with 14 additions and 14 deletions
|
@ -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")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue