Closes #25664: handled logger names in Unicode.

This commit is contained in:
Vinay Sajip 2015-12-26 12:21:47 +00:00
parent 20a003bea4
commit 82ea0f9517
1 changed files with 9 additions and 1 deletions

View File

@ -465,7 +465,15 @@ class Formatter(object):
record.message = record.getMessage()
if self.usesTime():
record.asctime = self.formatTime(record, self.datefmt)
s = self._fmt % record.__dict__
try:
s = self._fmt % record.__dict__
except UnicodeDecodeError as e:
# Issue 25664. The logger name may be Unicode. Try again ...
try:
record.name = record.name.decode('utf-8')
s = self._fmt % record.__dict__
except UnicodeDecodeError:
raise e
if record.exc_info:
# Cache the traceback text to avoid converting it multiple times
# (it's constant anyway)