# HG changeset patch # User Christian Boos # Date 1260449982 -3600 # Branch trunk # Node ID e3416da1b6c3f026d36065f92979ffba6e1c1e10 # Parent bd98b2c097fedd764e937d808080aa1eb78b426f Avoid spurious re-decoding of just UTF-8 encoded string, in the logger.StreamLogger. diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -821,9 +821,9 @@ 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 @@ #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: