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 kiminoa
Recipients Kronuz, docs@python, eric.araujo, ezio.melotti, kiminoa, vinay.sajip
Date 2013-02-21.02:06:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1361412419.94.0.368515263307.issue17155@psf.upfronthosting.co.za>
In-reply-to
Content
I'm running into similar issues with 2.6.7 and logging 0.4.9.6, where unicode strings are fine in print statements and codecs writes, but the same string is giving tracebacks for logging.  If it's an education issue, I'm not finding the education I need ... :-/

import logging
import codecs

# Unicode string
i = u'\u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044a'

# Print statement is fine
print "hi, i'm the string in question in a print statement: %s" % i

# Codecs write is fine
with codecs.open('/tmp/utf8', 'w', 'utf-8') as f:
    f.write(i)

# Logging gives a Traceback
log = logging.getLogger(__name__)
log.setLevel(logging.DEBUG)
handler = logging.FileHandler('/tmp/out', 'w', 'utf-8')
handler.setFormatter(logging.Formatter(u'[%(levelname)s] %(message)s'))
# I've also tried nixing setFormatter and going with the default
log.addHandler(handler)
log.debug(u"process_clusters: From CSV: %s", i)
# I've also tried a bare call to i, with and without the u in the message, and explicitly i.encode('utf8'); all Tracebacks.
History
Date User Action Args
2013-02-21 02:07:00kiminoasetrecipients: + kiminoa, vinay.sajip, ezio.melotti, eric.araujo, docs@python, Kronuz
2013-02-21 02:06:59kiminoasetmessageid: <1361412419.94.0.368515263307.issue17155@psf.upfronthosting.co.za>
2013-02-21 02:06:59kiminoalinkissue17155 messages
2013-02-21 02:06:59kiminoacreate