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 vinay.sajip
Recipients methane, vinay.sajip
Date 2009-09-25.17:09:50
SpamBayes Score 3.0446822e-06
Marked as misclassified No
Message-id <1253898591.95.0.989304139632.issue6991@psf.upfronthosting.co.za>
In-reply-to
Content
Your second example (logging_error.py) fails for the same reason -
you're writing a byte-string to a stream which is expecting Unicode. The
error occurs in logging only it tries encoding as UTF-8 as a last-ditch
attempt - and that only happens because of an earlier exception caused
by you not writing a Unicode string.

In summary: If you open a stream via codecs.open, whether directly or
through the logging module, you are expecting the stream to do encoding
for you. Therefore, you only write Unicode to the stream - never a
byte-string. If you have a byte-string in your application which you
have obtained from somewhere else, convert it to Unicode using whatever
encoding applies to the source. Then, send the resulting Unicode to the
encoding stream (or logger).
History
Date User Action Args
2009-09-25 17:09:52vinay.sajipsetrecipients: + vinay.sajip, methane
2009-09-25 17:09:51vinay.sajipsetmessageid: <1253898591.95.0.989304139632.issue6991@psf.upfronthosting.co.za>
2009-09-25 17:09:50vinay.sajiplinkissue6991 messages
2009-09-25 17:09:50vinay.sajipcreate