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 jonathan-lp
Recipients jonathan-lp
Date 2019-05-31.09:57:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1559296654.15.0.378802674413.issue37111@roundup.psfhosted.org>
In-reply-to
Content
Python is inconsistent in how it handles errors that have some unicode characters. It works to screen but fails to log

This works:
```
>>> import logging
>>> logging.error('จุด1')
ERROR:root:จุด1
```

The following breaks:

```
>>> import logging
>>> logging.basicConfig(filename='c:\\my_log.log')
>>> logging.error('จุด1')
```

This raises a unicode error:
UnicodeEncodeError: 'charmap' codec can't encode characters in position 11-13: character maps to <undefined>

Python 3.6.3

Given that the file created by the logger is utf-8, it's unclear why it doesn't work.

I found a workaround by using a Handler, but surely the loggers should all work the same way so that people don't get unpleasant surprises that even more painful to debug when things only break in certain logging modes?
History
Date User Action Args
2019-05-31 09:57:34jonathan-lpsetrecipients: + jonathan-lp
2019-05-31 09:57:34jonathan-lpsetmessageid: <1559296654.15.0.378802674413.issue37111@roundup.psfhosted.org>
2019-05-31 09:57:34jonathan-lplinkissue37111 messages
2019-05-31 09:57:33jonathan-lpcreate