]> granicus.if.org Git - python/commitdiff
Issue #7470: logging: fix bug in Unicode encoding fallback.
authorVinay Sajip <vinay_sajip@yahoo.co.uk>
Fri, 11 Dec 2009 09:16:01 +0000 (09:16 +0000)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>
Fri, 11 Dec 2009 09:16:01 +0000 (09:16 +0000)
Lib/logging/__init__.py
Misc/NEWS

index 3f8cf05b12d7132a2c32a7f967b541705f1b3e0d..e0d62813131024207f689e355358e2f5bbdae982 100644 (file)
@@ -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:
index e4c39185082cb3bd3b59b7991d68e8b8501da35a..38640a7940adab070c43ba320de420a3cd971ce2 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -15,6 +15,8 @@ Core and Builtins
 Library
 -------
 
+- Issue #7470: logging: fix bug in Unicode encoding fallback.
+
 - Issue #5949: fixed IMAP4_SSL hang when the IMAP server response is
   missing proper end-of-line termination.