New submission from Naoki INADA <songofaca...@gmail.com>: When stream is codecs.writer object, stream.write(string) does string.decode() internally and it may cause UnicodeDecodeError.
Then, fallback to utf-8 is not good. I think good fallback logic is: * When message is unicode, message.encode(stream.encoding or 'ascii', 'backslashreplace') * When message is bytes, message.encode('string_escape') Attached patch contains this logic, refactoring and test. ---------- components: Library (Lib) files: logging_encode.patch keywords: patch messages: 93100 nosy: naoki severity: normal status: open title: logging encoding failes some situation versions: Python 2.6, Python 2.7 Added file: http://bugs.python.org/file14970/logging_encode.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue6991> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com