mirror of
https://github.com/python/cpython.git
synced 2025-08-17 15:21:26 +00:00
gh-39615: Add warnings.warn() skip_file_prefixes support (#100840)
`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.
This commit is contained in:
parent
8cef9c0f92
commit
052f53d65d
12 changed files with 264 additions and 49 deletions
|
@ -1,9 +1,15 @@
|
|||
# Helper module for testing the skipmodules argument of warnings.warn()
|
||||
# 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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue