Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Lib/_pyio.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,16 @@ def close(self):

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:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
:class:`_pyio.IOBase` destructor now does nothing if getting the ``closed``
attribute fails to better mimick :class:`_io.IOBase` finalizer.