1
0
Fork 0
forked from github/pelican

Handle critical exception logging correctly in localized systems

Python generates certain exception messages (like IOError) in system
language, if locale is set. This ensures that the message is properly
converted to unicode in Python 2.
This commit is contained in:
Deniz Turgut 2013-05-04 04:55:42 -04:00
commit 084818b399

View file

@ -378,7 +378,13 @@ def main():
pelican.run()
except Exception as e:
logger.critical(e)
# localized systems have errors in native language if locale is set
# so convert the message to unicode with the correct encoding
msg = str(e)
if not six.PY3:
msg = msg.decode(locale.getpreferredencoding(False))
logger.critical(msg)
if (args.verbosity == logging.DEBUG):
raise