diff options
author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2010-06-11 22:56:50 (GMT) |
---|---|---|
committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2010-06-11 22:56:50 (GMT) |
commit | 936efc791a9d97e4d4a9db386dc419b7ab30dfab (patch) | |
tree | 13685fc6dc0b9faacd1bceb6c64d4509a880211d | |
parent | cca3a3f396a111c3b7bc766c601950acbf5d18fe (diff) | |
download | cpython-936efc791a9d97e4d4a9db386dc419b7ab30dfab.zip cpython-936efc791a9d97e4d4a9db386dc419b7ab30dfab.tar.gz cpython-936efc791a9d97e4d4a9db386dc419b7ab30dfab.tar.bz2 |
Issue #8924: logging: Improved error handling for Unicode in exception text.
-rw-r--r-- | Lib/logging/__init__.py | 8 | ||||
-rw-r--r-- | Misc/NEWS | 1 |
2 files changed, 8 insertions, 1 deletions
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py index 239ae61..80ec672 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 # @@ -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. |