[3.12] gh-130618: Fix parser error when using lambdas inside f-strings (GH-130638) (#130644)

(cherry picked from commit e06bebb87e)
This commit is contained in:
Pablo Galindo Salgado 2025-03-01 18:10:07 +00:00 committed by GitHub
parent 99e18abe6f
commit 0860d9c72f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 19 additions and 1 deletions

View file

@ -2030,6 +2030,18 @@ class GrammarTests(unittest.TestCase):
with self.assertRaises(Done):
foo().send(None)
def test_complex_lambda(self):
def test1(foo, bar):
return ""
def test2():
return f"{test1(
foo=lambda: '、、、、、、、、、、、、、、、、、',
bar=lambda: 'abcdefghijklmnopqrstuvwxyz 123456789 123456789',
)}"
self.assertEqual(test2(), "")
if __name__ == '__main__':
unittest.main()