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
diff --git a/Doc/library/warnings.rst b/Doc/library/warnings.rst
index 4ce88ab..4fec365 100644
--- a/Doc/library/warnings.rst
+++ b/Doc/library/warnings.rst
@@ -300,7 +300,7 @@
-------------------
-.. function:: warn(message, category=None, stacklevel=1)
+.. function:: warn(message, category=None, stacklevel=1, source=None)
Issue a warning, or maybe ignore it or raise an exception. The *category*
argument, if given, must be a warning category class (see above); it defaults to
@@ -318,6 +318,12 @@
source of :func:`deprecation` itself (since the latter would defeat the purpose
of the warning message).
+ *source*, if supplied, is the destroyed object which emitted a
+ :exc:`ResourceWarning`.
+
+ .. versionchanged:: 3.6
+ Added *source* parameter.
+
.. function:: warn_explicit(message, category, filename, lineno, module=None, registry=None, module_globals=None, source=None)