_pyio.IOBase destructor now does nothing if getting the closed
attribute fails to better mimick _io.IOBase finalizer.
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:
--- /dev/null
+:class:`_pyio.IOBase` destructor now does nothing if getting the ``closed``
+attribute fails to better mimick :class:`_io.IOBase` finalizer.