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).
This commit is contained in:
parent
5c15aba870
commit
8f96b8ec43
|
@ -735,7 +735,7 @@ class StreamHandler(Handler):
|
||||||
"""
|
"""
|
||||||
Flushes the stream.
|
Flushes the stream.
|
||||||
"""
|
"""
|
||||||
if self.stream:
|
if self.stream and hasattr(self.stream, "flush"):
|
||||||
self.stream.flush()
|
self.stream.flush()
|
||||||
|
|
||||||
def emit(self, record):
|
def emit(self, record):
|
||||||
|
@ -791,6 +791,7 @@ class FileHandler(StreamHandler):
|
||||||
"""
|
"""
|
||||||
if self.stream:
|
if self.stream:
|
||||||
self.flush()
|
self.flush()
|
||||||
|
if hasattr(self.stream, "close"):
|
||||||
self.stream.close()
|
self.stream.close()
|
||||||
StreamHandler.close(self)
|
StreamHandler.close(self)
|
||||||
self.stream = None
|
self.stream = None
|
||||||
|
|
Loading…
Reference in New Issue