mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 23:21:29 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			19 lines
		
	
	
	
		
			443 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			19 lines
		
	
	
	
		
			443 B
		
	
	
	
		
			Python
		
	
	
	
	
	
 | 
						|
# Test case taken from test_itertools
 | 
						|
# See http://mail.python.org/pipermail/python-dev/2005-November/058339.html
 | 
						|
 | 
						|
from itertools import tee
 | 
						|
 | 
						|
def leak():
 | 
						|
    def fib():
 | 
						|
        def yield_identity_forever(g):
 | 
						|
            while 1:
 | 
						|
                yield g
 | 
						|
        def _fib():
 | 
						|
            for i in yield_identity_forever(head):
 | 
						|
                yield i
 | 
						|
        head, tail, result = tee(_fib(), 3)
 | 
						|
        return result
 | 
						|
 | 
						|
    x = fib()
 | 
						|
    x.next()
 |