]> granicus.if.org Git - python/commitdiff
Closes #13232: Handle multiple encodings in exception logging.
authorVinay Sajip <vinay_sajip@yahoo.co.uk>
Mon, 24 Oct 2011 22:23:02 +0000 (23:23 +0100)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>
Mon, 24 Oct 2011 22:23:02 +0000 (23:23 +0100)
Lib/logging/__init__.py

index aaad89884f18a3ecedea8467e4b329d0bc600f4e..c18d5ba04eb5396396a87463b34215142e57e387 100644 (file)
@@ -478,8 +478,12 @@ class Formatter(object):
             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())
+                # See issue 8924.
+                # We also use replace for when there are multiple
+                # encodings, e.g. UTF-898 for the filesystem and latin-1
+                # for a script. See issue 13232.
+                s = s + record.exc_text.decode(sys.getfilesystemencoding(),
+                                               'replace')
         return s
 
 #