]> granicus.if.org Git - python/commitdiff
Set closed flag *after* calling flush().
authorGuido van Rossum <guido@python.org>
Tue, 10 Jul 2007 12:00:45 +0000 (12:00 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 10 Jul 2007 12:00:45 +0000 (12:00 +0000)
Lib/io.py

index 72c9e1785aa2331ef013d9652874e6f55ceea0bf..ed946659ef37e70898610b091ed39f7ea46ffa71 100644 (file)
--- 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()."""