Set closed flag *after* calling flush().

This commit is contained in:
Guido van Rossum 2007-07-10 12:00:45 +00:00
parent 47f17d0175
commit 469734b996
1 changed files with 4 additions and 2 deletions

View File

@ -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()."""