diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2023-07-05 23:31:37 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-05 23:31:37 (GMT) |
commit | bb17e6f5de2bca85746a06d504029f90e85e3892 (patch) | |
tree | 826075fb8af05894f14c348b1ac2c9f7041bb2dd /Lib | |
parent | a49a29f22bcc39376e760823ec512df831d2e828 (diff) | |
download | cpython-bb17e6f5de2bca85746a06d504029f90e85e3892.zip cpython-bb17e6f5de2bca85746a06d504029f90e85e3892.tar.gz cpython-bb17e6f5de2bca85746a06d504029f90e85e3892.tar.bz2 |
[3.12] gh-105340: include hidden fast-locals in locals() (GH-105715) (#106470)
gh-105340: include hidden fast-locals in locals() (GH-105715)
* gh-105340: include hidden fast-locals in locals()
(cherry picked from commit 104d7b760fed18055e4f04e5da3ca619e28bfc81)
Co-authored-by: Carl Meyer <carl@oddbird.net>
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_listcomps.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Lib/test/test_listcomps.py b/Lib/test/test_listcomps.py index c2cf058..9f28ced 100644 --- a/Lib/test/test_listcomps.py +++ b/Lib/test/test_listcomps.py @@ -539,6 +539,28 @@ class ListComprehensionTest(unittest.TestCase): self._check_in_scopes(code, {"x": True, "y": ["b"]}, scopes=["function"]) self._check_in_scopes(code, raises=NameError, scopes=["class"]) + def test_iter_var_available_in_locals(self): + code = """ + l = [1, 2] + y = 0 + items = [locals()["x"] for x in l] + items2 = [vars()["x"] for x in l] + items3 = [("x" in dir()) for x in l] + items4 = [eval("x") for x in l] + # x is available, and does not overwrite y + [exec("y = x") for x in l] + """ + self._check_in_scopes( + code, + { + "items": [1, 2], + "items2": [1, 2], + "items3": [True, True], + "items4": [1, 2], + "y": 0 + } + ) + __test__ = {'doctests' : doctests} |