Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cf672f1

Browse files
committed
Add test for local assigned to only in a nested list comp
1 parent 961dfe0 commit cf672f1

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

Lib/test/output/test_scope

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ test_scope
2020
19. var is bound and free in class
2121
20. interaction with trace function
2222
20. eval with free variables
23+
21. list comprehension with local variables

Lib/test/test_scope.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,3 +485,21 @@ def f(x):
485485
print "eval() should have failed, because code contained free vars"
486486

487487
warnings.resetwarnings()
488+
489+
print "21. list comprehension with local variables"
490+
491+
try:
492+
print bad
493+
except NameError:
494+
pass
495+
else:
496+
print "bad should not be defined"
497+
498+
def x():
499+
[bad for s in 'a b' for bad in s.split()]
500+
501+
x()
502+
try:
503+
print bad
504+
except NameError:
505+
pass

0 commit comments

Comments
 (0)