diff options
author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2008-06-17 11:02:14 (GMT) |
---|---|---|
committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2008-06-17 11:02:14 (GMT) |
commit | 8f96b8ec4303d5c54b9a20c963292dd98bf3a714 (patch) | |
tree | 4935ee6e92a62dc54645da245e1e5f44d4aeda2e /Lib/logging | |
parent | 5c15aba870511705e7a453729f3d0468617c5c4a (diff) | |
download | cpython-8f96b8ec4303d5c54b9a20c963292dd98bf3a714.zip cpython-8f96b8ec4303d5c54b9a20c963292dd98bf3a714.tar.gz cpython-8f96b8ec4303d5c54b9a20c963292dd98bf3a714.tar.bz2 |
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).
Diffstat (limited to 'Lib/logging')
-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 38bbae0..c0b20ea 100644 --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -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 |