Commits

Vinay Sajip  committed 8e85c46

Bug #3126: StreamHandler and FileHandler check before calling "flush" and "close" that the stream object has these, using hasattr (thanks to bobf for the patch).

  • Participants
  • Parent commits 98d012a
  • Branches legacy-trunk

Comments (0)

Files changed (1)

File Lib/logging/__init__.py

         """
         Flushes the stream.
         """
-        if self.stream:
+        if self.stream and hasattr(self.stream, "flush"):
             self.stream.flush()
 
     def emit(self, record):
         """
         if self.stream:
             self.flush()
-            self.stream.close()
+            if hasattr(self.stream, "close"):
+                self.stream.close()
             StreamHandler.close(self)
             self.stream = None