[Python-checkins] r64338 - python/trunk/Lib/logging/__init__.py
vinay.sajip
python-checkins at python.org
Tue Jun 17 13:02:14 CEST 2008
Author: vinay.sajip
Date: Tue Jun 17 13:02:14 2008
New Revision: 64338
Log:
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).
Modified:
python/trunk/Lib/logging/__init__.py
Modified: python/trunk/Lib/logging/__init__.py
==============================================================================
--- python/trunk/Lib/logging/__init__.py (original)
+++ python/trunk/Lib/logging/__init__.py Tue Jun 17 13:02:14 2008
@@ -735,7 +735,7 @@
"""
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 @@
"""
if self.stream:
self.flush()
- self.stream.close()
+ if hasattr(self.stream, "close"):
+ self.stream.close()
StreamHandler.close(self)
self.stream = None
More information about the Python-checkins
mailing list