Commit 4f6f7c5a authored by Victor Stinner's avatar Victor Stinner Committed by GitHub

bpo-18748: Fix _pyio.IOBase destructor (closed case) (GH-13952)

_pyio.IOBase destructor now does nothing if getting the closed
attribute fails to better mimick _io.IOBase finalizer.
parent 8a8b59c9
......@@ -405,6 +405,16 @@ class IOBase(metaclass=abc.ABCMeta):
def __del__(self):
"""Destructor. Calls close()."""
try:
closed = self.closed
except Exception:
# If getting closed fails, then the object is probably
# in an unusable state, so ignore.
return
if closed:
return
if _IOBASE_EMITS_UNRAISABLE:
self.close()
else:
......
:class:`_pyio.IOBase` destructor now does nothing if getting the ``closed``
attribute fails to better mimick :class:`_io.IOBase` finalizer.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment