[issue5170] logging to file + encoding

shamilbi report at bugs.python.org
Mon Apr 20 17:29:30 CEST 2009


shamilbi <shamilbi at gmail.com> added the comment:

(python 2.6.2, WinXP)
logging to console stopped working. Here is a workaround:

logging/__init__.py:
class StreamHandler(Handler):
    ...
    def emit(self, record):
    ...
                    if (isinstance(msg, unicode) or
                        getattr(stream, 'encoding', None) is None):
-                         stream.write(fs % msg)
+                         if stream == sys.stdout:
+                             print(msg)
+                         else:
+                             stream.write(fs % msg)

----------
status: closed -> open
type: crash -> behavior

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5170>
_______________________________________


More information about the Python-bugs-list mailing list