mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 03:44:55 +00:00 
			
		
		
		
	segfault the interpreter during weakref clean up. Now any new weakrefs created after __del__ is run are removed silently. Fixes bug #1377858 and the weakref_in_del crasher for new-style classes. Classic classes are still affected.
		
			
				
	
	
		
			17 lines
		
	
	
	
		
			305 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			17 lines
		
	
	
	
		
			305 B
		
	
	
	
		
			Python
		
	
	
	
	
	
import weakref
 | 
						|
 | 
						|
# http://python.org/sf/1377858
 | 
						|
# Fixed for new-style classes in 2.5c1.
 | 
						|
 | 
						|
ref = None
 | 
						|
 | 
						|
def test_weakref_in_del():
 | 
						|
    class Target():
 | 
						|
        def __del__(self):
 | 
						|
            global ref
 | 
						|
            ref = weakref.ref(self)
 | 
						|
 | 
						|
    w = Target()
 | 
						|
 | 
						|
if __name__ == '__main__':
 | 
						|
    test_weakref_in_del()
 |