diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2016-03-22 23:28:08 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2016-03-22 23:28:08 (GMT) |
commit | e19558af1b6979edf27f7a05a6e47a8b5d113390 (patch) | |
tree | f901801a0684eba2f662670a178c43d96918c4db /Lib/warnings.py | |
parent | 060f9bb6024580272440f57c612ca34d9beaa169 (diff) | |
download | cpython-e19558af1b6979edf27f7a05a6e47a8b5d113390.zip cpython-e19558af1b6979edf27f7a05a6e47a8b5d113390.tar.gz cpython-e19558af1b6979edf27f7a05a6e47a8b5d113390.tar.bz2 |
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
Diffstat (limited to 'Lib/warnings.py')
-rw-r--r-- | Lib/warnings.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/warnings.py b/Lib/warnings.py index 9fb21a8..d4f591e 100644 --- a/Lib/warnings.py +++ b/Lib/warnings.py @@ -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, |