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.7rc2~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=936efc791a9d97e4d4a9db386dc419b7ab30dfab;p=thirdparty%2FPython%2Fcpython.git Issue #8924: logging: Improved error handling for Unicode in exception text. --- diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py index 239ae61fadba..80ec6724e44c 100644 --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -473,7 +473,13 @@ class Formatter(object): 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 78d8cc70f951..0d353994ece6 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -21,6 +21,7 @@ Core and Builtins Library ------- +- Issue #8924: logging: Improved error handling for Unicode in exception text. - Issue #8948: cleanup functions and class / module setups and teardowns are now honored in unittest debug methods.