[issue12339] logging.Formatter.format() assumes exception to support str() method which is not true for many libraries.
Vinay Sajip
report at bugs.python.org
Wed Jun 15 15:59:45 CEST 2011
Vinay Sajip <vinay_sajip at yahoo.co.uk> added the comment:
This is happening because if you pass an object instead of a string as the first argument in a logging call, it's treated as a message object whose __str__() will be called to get the actual message when it's needed, as documented here:
http://docs.python.org/howto/logging.html#arbitrary-object-messages
If, instead, you do it like this:
# coding: utf-8
import logging
logging.basicConfig()
try:
raise Exception(u'ą')
except Exception:
logging.getLogger('general').exception(u'An error occurred')
you get
ERROR:general:An error occurred
Traceback (most recent call last):
File "bug_12339.py", line 6, in <module>
raise Exception(u'ą')
Exception: \u0105
----------
resolution: -> invalid
status: open -> closed
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12339>
_______________________________________
More information about the Python-bugs-list
mailing list