summaryrefslogtreecommitdiffstats
path: root/Lib/io.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-07-10 12:00:45 (GMT)
committerGuido van Rossum <guido@python.org>2007-07-10 12:00:45 (GMT)
commit469734b996915d2257639a671715539ad42e2576 (patch)
treea96f42f66959e129766ca4c61e36a5912b98ea97 /Lib/io.py
parent47f17d01751f0b8186d6e08f4019f5b1bacf9512 (diff)
downloadcpython-469734b996915d2257639a671715539ad42e2576.zip
cpython-469734b996915d2257639a671715539ad42e2576.tar.gz
cpython-469734b996915d2257639a671715539ad42e2576.tar.bz2
Set closed flag *after* calling flush().
Diffstat (limited to 'Lib/io.py')
-rw-r--r--Lib/io.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/io.py b/Lib/io.py
index 72c9e17..ed94665 100644
--- a/Lib/io.py
+++ b/Lib/io.py
@@ -227,8 +227,10 @@ class IOBase:
'closed' property (see below) to test.
"""
if not self.__closed:
- self.__closed = True
- self.flush()
+ try:
+ self.flush()
+ finally:
+ self.__closed = True
def __del__(self) -> None:
"""Destructor. Calls close()."""