[3.12] gh-108732: include comprehension locals in frame.f_locals (GH-109026) (#109097)

gh-108732: include comprehension locals in frame.f_locals (GH-109026)
(cherry picked from commit f2584eade3)

Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Radislav Chugunov <52372310+chgnrdv@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
This commit is contained in:
Miss Islington (bot) 2023-09-12 06:50:29 -07:00 committed by GitHub
parent af83d1e821
commit d533ab17ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 4 deletions

View file

@ -596,6 +596,13 @@ class ListComprehensionTest(unittest.TestCase):
"""
self._check_in_scopes(code, {"value": [1, None]})
def test_frame_locals(self):
code = """
val = [sys._getframe().f_locals for a in [0]][0]["a"]
"""
import sys
self._check_in_scopes(code, {"val": 0}, ns={"sys": sys})
__test__ = {'doctests' : doctests}