[3.13] gh-128396: Fix a crash when inline comprehension has the same … (#130311)

[3.13] gh-128396: Fix a crash when inline comprehension has the same local variable as the outside scope (GH-130235)
(cherry picked from commit ccf17323c2)
This commit is contained in:
Tian Gao 2025-02-19 12:40:03 -05:00 committed by GitHub
parent 5907cd6829
commit 094394a380
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 16 additions and 2 deletions

View file

@ -298,6 +298,12 @@ class TestFrameLocals(unittest.TestCase):
self.assertEqual(x, 2)
self.assertEqual(y, 3)
def test_closure_with_inline_comprehension(self):
lambda: k
k = 1
lst = [locals() for k in [0]]
self.assertEqual(lst[0]['k'], 0)
def test_as_dict(self):
x = 1
y = 2