summaryrefslogtreecommitdiffstats
path: root/Lib/logging
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)
commitf753d3366556294b23a67739de281895e8b44681 (patch)
treed2d05341ed33bd77a65082ef5eb77e782d3ea803 /Lib/logging
parent4595e518178f547966fab079351a77d11566cf33 (diff)
downloadcpython-f753d3366556294b23a67739de281895e8b44681.zip
cpython-f753d3366556294b23a67739de281895e8b44681.tar.gz
cpython-f753d3366556294b23a67739de281895e8b44681.tar.bz2
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 ba40067..b48bee8 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
#