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/_pyio.py b/Lib/_pyio.py
index c3ad81e..972c082 100644
--- a/Lib/_pyio.py
+++ b/Lib/_pyio.py
@@ -1514,7 +1514,7 @@
if self._fd >= 0 and self._closefd and not self.closed:
import warnings
warnings.warn('unclosed file %r' % (self,), ResourceWarning,
- stacklevel=2)
+ stacklevel=2, source=self)
self.close()
def __getstate__(self):