mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +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
|
|
@ -412,7 +412,8 @@ class BaseEventLoop(events.AbstractEventLoop):
|
|||
if compat.PY34:
|
||||
def __del__(self):
|
||||
if not self.is_closed():
|
||||
warnings.warn("unclosed event loop %r" % self, ResourceWarning)
|
||||
warnings.warn("unclosed event loop %r" % self, ResourceWarning,
|
||||
source=self)
|
||||
if not self.is_running():
|
||||
self.close()
|
||||
|
||||
|
|
|
|||
|
|
@ -122,7 +122,8 @@ class BaseSubprocessTransport(transports.SubprocessTransport):
|
|||
if compat.PY34:
|
||||
def __del__(self):
|
||||
if not self._closed:
|
||||
warnings.warn("unclosed transport %r" % self, ResourceWarning)
|
||||
warnings.warn("unclosed transport %r" % self, ResourceWarning,
|
||||
source=self)
|
||||
self.close()
|
||||
|
||||
def get_pid(self):
|
||||
|
|
|
|||
|
|
@ -86,7 +86,8 @@ class _ProactorBasePipeTransport(transports._FlowControlMixin,
|
|||
if compat.PY34:
|
||||
def __del__(self):
|
||||
if self._sock is not None:
|
||||
warnings.warn("unclosed transport %r" % self, ResourceWarning)
|
||||
warnings.warn("unclosed transport %r" % self, ResourceWarning,
|
||||
source=self)
|
||||
self.close()
|
||||
|
||||
def _fatal_error(self, exc, message='Fatal error on pipe transport'):
|
||||
|
|
|
|||
|
|
@ -573,7 +573,8 @@ class _SelectorTransport(transports._FlowControlMixin,
|
|||
if compat.PY34:
|
||||
def __del__(self):
|
||||
if self._sock is not None:
|
||||
warnings.warn("unclosed transport %r" % self, ResourceWarning)
|
||||
warnings.warn("unclosed transport %r" % self, ResourceWarning,
|
||||
source=self)
|
||||
self._sock.close()
|
||||
|
||||
def _fatal_error(self, exc, message='Fatal error on transport'):
|
||||
|
|
|
|||
|
|
@ -324,7 +324,8 @@ class _SSLProtocolTransport(transports._FlowControlMixin,
|
|||
if compat.PY34:
|
||||
def __del__(self):
|
||||
if not self._closed:
|
||||
warnings.warn("unclosed transport %r" % self, ResourceWarning)
|
||||
warnings.warn("unclosed transport %r" % self, ResourceWarning,
|
||||
source=self)
|
||||
self.close()
|
||||
|
||||
def pause_reading(self):
|
||||
|
|
|
|||
|
|
@ -378,7 +378,8 @@ class _UnixReadPipeTransport(transports.ReadTransport):
|
|||
if compat.PY34:
|
||||
def __del__(self):
|
||||
if self._pipe is not None:
|
||||
warnings.warn("unclosed transport %r" % self, ResourceWarning)
|
||||
warnings.warn("unclosed transport %r" % self, ResourceWarning,
|
||||
source=self)
|
||||
self._pipe.close()
|
||||
|
||||
def _fatal_error(self, exc, message='Fatal error on pipe transport'):
|
||||
|
|
@ -567,7 +568,8 @@ class _UnixWritePipeTransport(transports._FlowControlMixin,
|
|||
if compat.PY34:
|
||||
def __del__(self):
|
||||
if self._pipe is not None:
|
||||
warnings.warn("unclosed transport %r" % self, ResourceWarning)
|
||||
warnings.warn("unclosed transport %r" % self, ResourceWarning,
|
||||
source=self)
|
||||
self._pipe.close()
|
||||
|
||||
def abort(self):
|
||||
|
|
|
|||
|
|
@ -159,7 +159,8 @@ class PipeHandle:
|
|||
|
||||
def __del__(self):
|
||||
if self._handle is not None:
|
||||
warnings.warn("unclosed %r" % self, ResourceWarning)
|
||||
warnings.warn("unclosed %r" % self, ResourceWarning,
|
||||
source=self)
|
||||
self.close()
|
||||
|
||||
def __enter__(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue