summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_fstring.py
diff options
context:
space:
mode:
authorLysandros Nikolaou <lisandrosnik@gmail.com>2023-04-24 18:30:21 (GMT)
committerGitHub <noreply@github.com>2023-04-24 18:30:21 (GMT)
commitcb157a1a353675cb6f08bdae5d7aadd6b28bb0a9 (patch)
treeb833923555d01ad4cc45e6e89bb2fc710fda5a08 /Lib/test/test_fstring.py
parentab25c7e3112b24a4cd8cb626bbd924c57af0fe1c (diff)
downloadcpython-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.py10
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")