From cf672f15e0b31eaff58e54dbbe62a2d52d49a63c Mon Sep 17 00:00:00 2001 From: Jeremy Hylton Date: Thu, 18 Oct 2001 16:23:11 +0000 Subject: [PATCH] Add test for local assigned to only in a nested list comp --- Lib/test/output/test_scope | 1 + Lib/test/test_scope.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/Lib/test/output/test_scope b/Lib/test/output/test_scope index 55a8787aadc..04dacaac125 100644 --- a/Lib/test/output/test_scope +++ b/Lib/test/output/test_scope @@ -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 diff --git a/Lib/test/test_scope.py b/Lib/test/test_scope.py index 1633b87be33..18dd0c74909 100644 --- a/Lib/test/test_scope.py +++ b/Lib/test/test_scope.py @@ -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