From: Vinay Sajip Date: Fri, 11 Jun 2010 22:56:50 +0000 (+0000) Subject: Issue #8924: logging: Improved error handling for Unicode in exception text. X-Git-Tag: v2.6.6rc1~196 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f753d3366556294b23a67739de281895e8b44681;p=python Issue #8924: logging: Improved error handling for Unicode in exception text. --- diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py index ba40067b61..b48bee85bd 100644 --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -445,7 +445,13 @@ class Formatter: if record.exc_text: if s[-1:] != "\n": s = s + "\n" - s = s + record.exc_text + try: + s = s + record.exc_text + except UnicodeError: + # Sometimes filenames have non-ASCII chars, which can lead + # to errors when s is Unicode and record.exc_text is str + # See issue 8924 + s = s + record.exc_text.decode(sys.getfilesystemencoding()) return s # diff --git a/Misc/NEWS b/Misc/NEWS index 7ab2d91de4..fee5682cd4 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -71,6 +71,8 @@ C-API Library ------- +- Issue #8924: logging: Improved error handling for Unicode in exception text. + - Fix codecs.escape_encode to return the correct consumed size. - Issue #6470: Drop UNC prefix in FixTk.