mirror of https://github.com/python/cpython
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.
|
||||
"""
|
||||
if self.stream:
|
||||
if self.stream and hasattr(self.stream, "flush"):
|
||||
self.stream.flush()
|
||||
|
||||
def emit(self, record):
|
||||
|
@ -791,6 +791,7 @@ class FileHandler(StreamHandler):
|
|||
"""
|
||||
if self.stream:
|
||||
self.flush()
|
||||
if hasattr(self.stream, "close"):
|
||||
self.stream.close()
|
||||
StreamHandler.close(self)
|
||||
self.stream = None
|
||||
|
|
Loading…
Reference in New Issue