summaryrefslogtreecommitdiffstats
path: root/Lib/logging
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2009-04-16 19:07:37 (GMT)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2009-04-16 19:07:37 (GMT)
commit74f045088d4dd1fd2485631efccda9de65200a39 (patch)
treeb906970f5eda5be7a6c3064e8fba80e60a6b268f /Lib/logging
parent76162e305cedb4b332a6804df815044f297b4e95 (diff)
downloadcpython-74f045088d4dd1fd2485631efccda9de65200a39.zip
cpython-74f045088d4dd1fd2485631efccda9de65200a39.tar.gz
cpython-74f045088d4dd1fd2485631efccda9de65200a39.tar.bz2
Issue #5768: Change to Unicode output logic and test case for same.
Diffstat (limited to 'Lib/logging')
-rw-r--r--Lib/logging/__init__.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py
index e7eb51d..d20b37b 100644
--- a/Lib/logging/__init__.py
+++ b/Lib/logging/__init__.py
@@ -753,7 +753,7 @@ class StreamHandler(Handler):
The record is then written to the stream with a trailing newline. If
exception information is present, it is formatted using
traceback.print_exception and appended to the stream. If the stream
- has an 'encoding' attribute, it is used to encode the message before
+ has an 'encoding' attribute, it is used to determine how to do the
output to the stream.
"""
try:
@@ -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()