aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_listcomps.py
diff options
context:
space:
mode:
authorCarl Meyer <carl@oddbird.net>2024-02-07 11:56:16 -0500
committerGitHub <noreply@github.com>2024-02-07 16:56:16 +0000
commitfedbf77191ea9d6515b39f958cc9e588d23517c9 (patch)
treecd4941e9d79c8a6cc4f3e4d86d7ffa46a7f5694a /Lib/test/test_listcomps.py
parent8a3c499ffe7e15297dd4c0b446a0b97b4d32108a (diff)
downloadcpython-fedbf77191ea9d6515b39f958cc9e588d23517c9.tar.gz
cpython-fedbf77191ea9d6515b39f958cc9e588d23517c9.zip
gh-114828: Fix __class__ in class-scope inlined comprehensions (#115139)
Diffstat (limited to 'Lib/test/test_listcomps.py')
-rw-r--r--Lib/test/test_listcomps.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_listcomps.py b/Lib/test/test_listcomps.py
index f95a78aff0c..2868dd01545 100644
--- a/Lib/test/test_listcomps.py
+++ b/Lib/test/test_listcomps.py
@@ -156,6 +156,18 @@ class ListComprehensionTest(unittest.TestCase):
self.assertEqual(C.y, [4, 4, 4, 4, 4])
self.assertIs(C().method(), C)
+ def test_references_super(self):
+ code = """
+ res = [super for x in [1]]
+ """
+ self._check_in_scopes(code, outputs={"res": [super]})
+
+ def test_references___class__(self):
+ code = """
+ res = [__class__ for x in [1]]
+ """
+ self._check_in_scopes(code, raises=NameError)
+
def test_inner_cell_shadows_outer(self):
code = """
items = [(lambda: i) for i in range(5)]