mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 23:21:29 +00:00 
			
		
		
		
	Add test for local assigned to only in a nested list comp
This commit is contained in:
		
							parent
							
								
									961dfe0d85
								
							
						
					
					
						commit
						cf672f15e0
					
				
					 2 changed files with 19 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -485,3 +485,21 @@ def f(x):
 | 
			
		|||
    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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue