Message344053
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? |
|
Date |
User |
Action |
Args |
2019-05-31 09:57:34 | jonathan-lp | set | recipients:
+ jonathan-lp |
2019-05-31 09:57:34 | jonathan-lp | set | messageid: <1559296654.15.0.378802674413.issue37111@roundup.psfhosted.org> |
2019-05-31 09:57:34 | jonathan-lp | link | issue37111 messages |
2019-05-31 09:57:33 | jonathan-lp | create | |
|