Author vinay.sajip
Recipients shamilbi, vinay.sajip
Date 2009-04-22.11:35:17
SpamBayes Score 1.89352e-10
Marked as misclassified No
Message-id <1240400118.88.0.695125715467.issue5170@psf.upfronthosting.co.za>
In-reply-to
Content
> 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 ;-)
History
Date User Action Args
2009-04-22 11:35:19vinay.sajipsetrecipients: + vinay.sajip, shamilbi
2009-04-22 11:35:18vinay.sajipsetmessageid: <1240400118.88.0.695125715467.issue5170@psf.upfronthosting.co.za>
2009-04-22 11:35:17vinay.sajiplinkissue5170 messages
2009-04-22 11:35:17vinay.sajipcreate