mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 21:51:50 +00:00 
			
		
		
		
	 052f53d65d
			
		
	
	
		052f53d65d
		
			
		
	
	
	
	
		
			
			`warnings.warn()` gains the ability to skip stack frames based on code filename prefix rather than only a numeric `stacklevel=` via a new `skip_file_prefixes=` keyword argument.
		
			
				
	
	
		
			15 lines
		
	
	
	
		
			466 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			15 lines
		
	
	
	
		
			466 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| # Helper module for testing stacklevel and skip_file_prefixes arguments
 | |
| # of warnings.warn()
 | |
| 
 | |
| import warnings
 | |
| from test.test_warnings.data import package_helper
 | |
| 
 | |
| def outer(message, stacklevel=1):
 | |
|     inner(message, stacklevel)
 | |
| 
 | |
| def inner(message, stacklevel=1):
 | |
|     warnings.warn(message, stacklevel=stacklevel)
 | |
| 
 | |
| def package(message, *, stacklevel):
 | |
|     package_helper.inner_api(message, stacklevel=stacklevel,
 | |
|                              warnings_module=warnings)
 |