diff options
author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2009-12-11 09:16:01 (GMT) |
---|---|---|
committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2009-12-11 09:16:01 (GMT) |
commit | 5cc4e2a04035ff823930aa39d88fb6678654637e (patch) | |
tree | a01382dbfb368673191f24e7fac8eccb56d53ddc /Lib/logging | |
parent | 6c4847fbee5112ae79f5798d0cac8a7515388365 (diff) | |
download | cpython-5cc4e2a04035ff823930aa39d88fb6678654637e.zip cpython-5cc4e2a04035ff823930aa39d88fb6678654637e.tar.gz cpython-5cc4e2a04035ff823930aa39d88fb6678654637e.tar.bz2 |
Issue #7470: logging: fix bug in Unicode encoding fallback.
Diffstat (limited to 'Lib/logging')
-rw-r--r-- | Lib/logging/__init__.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py index 3f8cf05..e0d6281 100644 --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -821,9 +821,9 @@ class StreamHandler(Handler): try: if (isinstance(msg, unicode) and getattr(stream, 'encoding', None)): - fs = fs.decode(stream.encoding) + ufs = fs.decode(stream.encoding) try: - stream.write(fs % msg) + stream.write(ufs % msg) except UnicodeEncodeError: #Printing to terminals sometimes fails. For example, #with an encoding of 'cp1251', the above write will @@ -831,7 +831,7 @@ class StreamHandler(Handler): #the codecs module, but fail when writing to a #terminal even when the codepage is set to cp1251. #An extra encoding step seems to be needed. - stream.write((fs % msg).encode(stream.encoding)) + stream.write((ufs % msg).encode(stream.encoding)) else: stream.write(fs % msg) except UnicodeError: |