(original) (raw)
changeset: 99678:512a628c683e branch: 2.7 parent: 99671:deda5b5160d2 user: Vinay Sajip <vinay_sajip@yahoo.co.uk> date: Sat Dec 26 12:21:47 2015 +0000 files: Lib/logging/__init__.py description: Closes #25664: handled logger names in Unicode. diff -r deda5b5160d2 -r 512a628c683e Lib/logging/__init__.py --- a/Lib/logging/__init__.py Thu Dec 24 11:51:24 2015 +0200 +++ b/Lib/logging/__init__.py Sat Dec 26 12:21:47 2015 +0000 @@ -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) </vinay_sajip@yahoo.co.uk>