summaryrefslogtreecommitdiff
path: root/Lib/logging
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2010-06-11 22:56:50 +0000
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2010-06-11 22:56:50 +0000
commitd7f6f11adb9c420f6bd9fcdaed5b7b491499ecae (patch)
tree83ef7f09e370bf6be59c6d0680bc1c66ecdf42c2 /Lib/logging
parentd6f3aa2e45d501094ecb43e051394136e1d5a799 (diff)
downloadcpython-d7f6f11adb9c420f6bd9fcdaed5b7b491499ecae.tar.gz
Issue #8924: logging: Improved error handling for Unicode in exception text.
Diffstat (limited to 'Lib/logging')
-rw-r--r--Lib/logging/__init__.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py
index 239ae61fad..80ec6724e4 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
#