]> granicus.if.org Git - python/commitdiff
Change to flush and close logic to fix #1760556.
authorVinay Sajip <vinay_sajip@yahoo.co.uk>
Thu, 27 Sep 2007 05:34:45 +0000 (05:34 +0000)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>
Thu, 27 Sep 2007 05:34:45 +0000 (05:34 +0000)
Lib/logging/__init__.py

index 4bb8cf446fdbb98e01d16504bfbd392c6044fb9b..c7058d803a8bdce05a9d54a7472e0f58afc7a73f 100644 (file)
@@ -728,7 +728,8 @@ class StreamHandler(Handler):
         """
         Flushes the stream.
         """
-        self.stream.flush()
+        if self.stream:
+            self.stream.flush()
 
     def emit(self, record):
         """
@@ -778,9 +779,11 @@ class FileHandler(StreamHandler):
         """
         Closes the stream.
         """
-        self.flush()
-        self.stream.close()
-        StreamHandler.close(self)
+        if self.stream:
+            self.flush()
+            self.stream.close()
+            StreamHandler.close(self)
+            self.stream = None
 
     def _open(self):
         """