]> granicus.if.org Git - python/commitdiff
Bug #3126: StreamHandler and FileHandler check before calling "flush" and "close...
authorVinay Sajip <vinay_sajip@yahoo.co.uk>
Tue, 17 Jun 2008 11:02:14 +0000 (11:02 +0000)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>
Tue, 17 Jun 2008 11:02:14 +0000 (11:02 +0000)
Lib/logging/__init__.py

index 38bbae036fffdcd0ffb4b16687b7ee79d2aee73c..c0b20ea01c13aa2b2290e779260f2dd1a87d781e 100644 (file)
@@ -735,7 +735,7 @@ class StreamHandler(Handler):
         """
         Flushes the stream.
         """
-        if self.stream:
+        if self.stream and hasattr(self.stream, "flush"):
             self.stream.flush()
 
     def emit(self, record):
@@ -791,7 +791,8 @@ class FileHandler(StreamHandler):
         """
         if self.stream:
             self.flush()
-            self.stream.close()
+            if hasattr(self.stream, "close"):
+                self.stream.close()
             StreamHandler.close(self)
             self.stream = None