mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 05:31:20 +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.
		
			
				
	
	
		
			10 lines
		
	
	
	
		
			283 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			10 lines
		
	
	
	
		
			283 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| # helper to the helper for testing skip_file_prefixes.
 | |
| 
 | |
| import os
 | |
| 
 | |
| package_path = os.path.dirname(__file__)
 | |
| 
 | |
| def inner_api(message, *, stacklevel, warnings_module):
 | |
|     warnings_module.warn(
 | |
|             message, stacklevel=stacklevel,
 | |
|             skip_file_prefixes=(package_path,))
 |