This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author methane
Recipients methane
Date 2009-09-25.05:29:22
SpamBayes Score 0.0009984588
Marked as misclassified No
Message-id <1253856567.46.0.952425276077.issue6991@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2009-09-25 05:29:27methanesetrecipients: + methane
2009-09-25 05:29:27methanesetmessageid: <1253856567.46.0.952425276077.issue6991@psf.upfronthosting.co.za>
2009-09-25 05:29:25methanelinkissue6991 messages
2009-09-25 05:29:24methanecreate