◐ Shell
clean mode source ↗

Issue 5768: logging don't encode Unicode message correctly.

I think that in r69448, the test does not match the code:
codecs.getwriter('cp1251') has no attribute 'encoding', and no function
in test_logging ever pass a stream with an explicit encoding.

Also, the test in emit() should be reversed, otherwise msg.encode() is
called only when msg is a 8bit string. And in this case, a unicode
string should be passed to the stream.

See attached patch.
The codecs.getwriter should probably grow an 'encoding' attribute
automatically, but this is another issue.