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/Lib/asyncore.py b/Lib/asyncore.py
index 3b51f0f..4b046d6 100644
--- a/Lib/asyncore.py
+++ b/Lib/asyncore.py
@@ -595,7 +595,8 @@
def __del__(self):
if self.fd >= 0:
- warnings.warn("unclosed file %r" % self, ResourceWarning)
+ warnings.warn("unclosed file %r" % self, ResourceWarning,
+ source=self)
self.close()
def recv(self, *args):