Vinay Sajip <vinay_sa...@yahoo.co.uk> added the comment: > i think it's all about the difference betwin print(msg) and > sys.stdout.write('%s\n' % msg)
Yes. Actually, it's about what streams will accept. For example, a stream opened with codecs.open(encoding='cp1251') will accept a Unicode string and encode it before output. Likewise, a StringIO wrapped inside a writer obtained from the codecs module. However, stdout and stderr are of type file and seem to behave differently - they behave as expected if I encode the value written to them, but fail if I write a Unicode string to them. I don't think special-casing for sys.stdout and sys.stderr in the logging code is the correct approach. Better to put a conditional encoding step when it's needed - now I just need to figure out all the cases when it's needed ;-) ---------- resolution: fixed -> accepted _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue5170> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com