From 4df367c08d042f2bc6b789d197c86cf4c13a15df Mon Sep 17 00:00:00 2001 From: Vinay Sajip Date: Thu, 27 Sep 2007 05:34:45 +0000 Subject: Change to flush and close logic to fix #1760556. --- Lib/logging/__init__.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py index 4bb8cf4..c7058d8 100644 --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -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): """ -- cgit v0.12