Message345432
> What logging does when UnicodeEncodeError is happened?
Hm, it seems logging does best job, show enough information to stderr.
But sometime, Python is embedded in web servers and there is no stderr. pythonw.exe may not have stderr too....
I still feel backslashreplace is better default error handler. But it's not strong opinion and it shouldn't block this issue. Go ahead.
$ cat x.py
import logging
logging.basicConfig(filename="mylog.txt")
msg = "hello, はろー"
logging.error(msg)
$ LC_ALL=en_US.US-ASCII python3 x.py
--- Logging error ---
Traceback (most recent call last):
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/logging/__init__.py", line 1037, in emit
stream.write(msg + self.terminator)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 18-20: ordinal not in range(128)
Call stack:
File "x.py", line 5, in <module>
logging.error(msg)
Message: 'hello, \u306f\u308d\u30fc'
Arguments: () |
|
Date |
User |
Action |
Args |
2019-06-13 00:10:25 | methane | set | recipients:
+ methane, paul.moore, vinay.sajip, tim.golden, SilentGhost, zach.ware, steve.dower, jonathan-lp |
2019-06-13 00:10:25 | methane | set | messageid: <1560384625.29.0.702302599764.issue37111@roundup.psfhosted.org> |
2019-06-13 00:10:25 | methane | link | issue37111 messages |
2019-06-13 00:10:25 | methane | create | |
|