diff options
Diffstat (limited to 'Lib/logging/__init__.py')
-rw-r--r-- | Lib/logging/__init__.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py index 742eac2682b..9727d4f091a 100644 --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -731,7 +731,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): @@ -787,7 +787,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 |