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:
parent
50505dfd71
commit
084818b399
1 changed files with 7 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue