summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2010-06-11 22:56:50 (GMT)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2010-06-11 22:56:50 (GMT)
commit936efc791a9d97e4d4a9db386dc419b7ab30dfab (patch)
tree13685fc6dc0b9faacd1bceb6c64d4509a880211d
parentcca3a3f396a111c3b7bc766c601950acbf5d18fe (diff)
downloadcpython-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__.py8
-rw-r--r--Misc/NEWS1
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
#
diff --git a/Misc/NEWS b/Misc/NEWS
index 78d8cc7..0d35399 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.