mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-114828: Fix __class__ in class-scope inlined comprehensions (#115139)
This commit is contained in:
parent
8a3c499ffe
commit
fedbf77191
3 changed files with 33 additions and 0 deletions
|
@ -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)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue