Linux binary: Do not fail on system with invalid locale info. Instead default to using the UTF-8 encoding on these systems. Fixes #1343444 [calibre crash with utf_8_valencia](https://bugs.launchpad.net/calibre/+bug/1343444)

This commit is contained in:
Kovid Goyal 2014-07-18 07:59:30 +05:30
parent ba75506ee3
commit 4b8f7184fb

View File

@ -337,7 +337,10 @@ class LinuxFreeze(Command):
enc = locale.nl_langinfo(locale.CODESET)
if not enc or enc.lower() == 'ascii':
enc = 'UTF-8'
enc = codecs.lookup(enc).name
try:
enc = codecs.lookup(enc).name
except LookupError:
enc = 'UTF-8'
sys.setdefaultencoding(enc)
del sys.setdefaultencoding