]> granicus.if.org Git - python/commitdiff
Add test for local assigned to only in a nested list comp
authorJeremy Hylton <jeremy@alum.mit.edu>
Thu, 18 Oct 2001 16:23:11 +0000 (16:23 +0000)
committerJeremy Hylton <jeremy@alum.mit.edu>
Thu, 18 Oct 2001 16:23:11 +0000 (16:23 +0000)
Lib/test/output/test_scope
Lib/test/test_scope.py

index 55a8787aadc624e2fb6481c0eb7db2b1ce81d1ab..04dacaac125fd6013c8effcc508e50eced520563 100644 (file)
@@ -20,3 +20,4 @@ test_scope
 19. var is bound and free in class
 20. interaction with trace function
 20. eval with free variables
+21. list comprehension with local variables
index 1633b87be33030068b54b8269d8758f5dd7d47a0..18dd0c749097321b58e05522a6c91663407302d6 100644 (file)
@@ -485,3 +485,21 @@ else:
     print "eval() should have failed, because code contained free vars"
 
 warnings.resetwarnings()
+
+print "21. list comprehension with local variables"
+
+try:
+    print bad
+except NameError:
+    pass
+else:
+    print "bad should not be defined"
+
+def x():
+    [bad for s in 'a b' for bad in s.split()]
+
+x()
+try:
+    print bad
+except NameError:
+    pass