(original) (raw)
changeset: 73108:4bb1dc4e2cec branch: 2.7 user: Vinay Sajip <vinay_sajip@yahoo.co.uk> date: Mon Oct 24 23:23:02 2011 +0100 files: Lib/logging/__init__.py description: Closes #13232: Handle multiple encodings in exception logging. diff -r 817946aadecb -r 4bb1dc4e2cec Lib/logging/__init__.py --- a/Lib/logging/__init__.py Mon Oct 24 21:29:20 2011 +0300 +++ b/Lib/logging/__init__.py Mon Oct 24 23:23:02 2011 +0100 @@ -478,8 +478,12 @@ 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 # </vinay_sajip@yahoo.co.uk>