diff options
author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2015-12-26 12:21:47 (GMT) |
---|---|---|
committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2015-12-26 12:21:47 (GMT) |
commit | 82ea0f9517a1b799e7457fd6afa19b9c2d75da7f (patch) | |
tree | b5c243c59f1d2e32272e4738043cae306e9a4075 | |
parent | 20a003bea45a87e855826ddd0998d6ac389628d9 (diff) | |
download | cpython-82ea0f9517a1b799e7457fd6afa19b9c2d75da7f.zip cpython-82ea0f9517a1b799e7457fd6afa19b9c2d75da7f.tar.gz cpython-82ea0f9517a1b799e7457fd6afa19b9c2d75da7f.tar.bz2 |
Closes #25664: handled logger names in Unicode.
-rw-r--r-- | Lib/logging/__init__.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py index fa9ebe8..caf151d 100644 --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -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) |