@@ -385,25 +385,25 @@ def test_global_outside_cellvar_inside_plus_freevar(self):
385
385
code = """
386
386
a = 1
387
387
def f():
388
- [(lambda: b) for b in [a]]
389
- return b
388
+ func, = [(lambda: b) for b in [a]]
389
+ return b, func()
390
390
x = f()
391
391
"""
392
392
self ._check_in_scopes (
393
- code , {"x" : 2 }, ns = {"b" : 2 }, scopes = ["function" , "module" ])
393
+ code , {"x" : ( 2 , 1 ) }, ns = {"b" : 2 }, scopes = ["function" , "module" ])
394
394
# inside a class, the `a = 1` assignment is not visible
395
395
self ._check_in_scopes (code , raises = NameError , scopes = ["class" ])
396
396
397
397
def test_cell_in_nested_comprehension (self ):
398
398
code = """
399
399
a = 1
400
400
def f():
401
- [[lambda: b for b in c] + [b] for c in [[a]]]
402
- return b
401
+ (func, inner_b), = [[lambda: b for b in c] + [b] for c in [[a]]]
402
+ return b, inner_b, func()
403
403
x = f()
404
404
"""
405
405
self ._check_in_scopes (
406
- code , {"x" : 2 }, ns = {"b" : 2 }, scopes = ["function" , "module" ])
406
+ code , {"x" : ( 2 , 2 , 1 ) }, ns = {"b" : 2 }, scopes = ["function" , "module" ])
407
407
# inside a class, the `a = 1` assignment is not visible
408
408
self ._check_in_scopes (code , raises = NameError , scopes = ["class" ])
409
409
0 commit comments