New submission from Jonathan <[email protected]>:
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?
----------
messages: 344053
nosy: jonathan-lp
priority: normal
severity: normal
status: open
title: Logging - Inconsistent behaviour when handling unicode
versions: Python 3.6
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue37111>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com