diff options
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/logging/__init__.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py index 4bb8cf446f..c7058d803a 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): """ |