[Python-checkins] cpython (2.7): Closes #25664: handled logger names in Unicode.

vinay.sajip python-checkins at python.org
Sat Dec 26 07:22:51 EST 2015


https://hg.python.org/cpython/rev/512a628c683e
changeset:   99678:512a628c683e
branch:      2.7
parent:      99671:deda5b5160d2
user:        Vinay Sajip <vinay_sajip at yahoo.co.uk>
date:        Sat Dec 26 12:21:47 2015 +0000
summary:
  Closes #25664: handled logger names in Unicode.

files:
  Lib/logging/__init__.py |  10 +++++++++-
  1 files changed, 9 insertions(+), 1 deletions(-)


diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py
--- a/Lib/logging/__init__.py
+++ b/Lib/logging/__init__.py
@@ -465,7 +465,15 @@
         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)

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list