summaryrefslogtreecommitdiffstats
path: root/Lib/logging
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/logging')
-rw-r--r--Lib/logging/__init__.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py
index 8c2a38c..6ce8364 100644
--- a/Lib/logging/__init__.py
+++ b/Lib/logging/__init__.py
@@ -764,11 +764,11 @@ class StreamHandler(Handler):
stream.write(fs % msg)
else:
try:
- if (isinstance(msg, unicode) or
- getattr(stream, 'encoding', None) is None):
- stream.write(fs % msg)
+ if (isinstance(msg, unicode) and
+ getattr(stream, 'encoding', None)):
+ stream.write(fs.decode(stream.encoding) % msg)
else:
- stream.write(fs % msg.encode(stream.encoding))
+ stream.write(fs % msg)
except UnicodeError:
stream.write(fs % msg.encode("UTF-8"))
self.flush()