mirror of
https://github.com/python/cpython.git
synced 2025-10-07 15:42:02 +00:00
Add a source parameter to warnings.warn()
Issue #26604: * Add a new optional source parameter to _warnings.warn() and warnings.warn() * Modify asyncore, asyncio and _pyio modules to set the source parameter when logging a ResourceWarning warning
This commit is contained in:
parent
060f9bb602
commit
e19558af1b
13 changed files with 34 additions and 19 deletions
|
@ -233,7 +233,7 @@ def _next_external_frame(frame):
|
|||
|
||||
|
||||
# Code typically replaced by _warnings
|
||||
def warn(message, category=None, stacklevel=1):
|
||||
def warn(message, category=None, stacklevel=1, source=None):
|
||||
"""Issue a warning, or maybe ignore it or raise an exception."""
|
||||
# Check if message is already a Warning object
|
||||
if isinstance(message, Warning):
|
||||
|
@ -283,7 +283,7 @@ def warn(message, category=None, stacklevel=1):
|
|||
filename = module
|
||||
registry = globals.setdefault("__warningregistry__", {})
|
||||
warn_explicit(message, category, filename, lineno, module, registry,
|
||||
globals)
|
||||
globals, source)
|
||||
|
||||
def warn_explicit(message, category, filename, lineno,
|
||||
module=None, registry=None, module_globals=None,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue