[r21489]GrampsLocale: Handle errors in getting collation key from locale module

svn: r21497
This commit is contained in:
John Ralls 2013-02-28 19:22:43 +00:00
parent f309f210d1
commit dede164e69

View File

@ -527,6 +527,7 @@ class GrampsLocale(object):
#ICU can digest strings and unicode #ICU can digest strings and unicode
return self.collator.getCollationKey(string).getByteArray() return self.collator.getCollationKey(string).getByteArray()
else: else:
try:
base_locale = locale.getlocale(locale.LC_COLLATE) base_locale = locale.getlocale(locale.LC_COLLATE)
locale.setlocale(locale.LC_COLLATE, self.collation) locale.setlocale(locale.LC_COLLATE, self.collation)
#locale in Python2 can't. #locale in Python2 can't.
@ -536,6 +537,11 @@ class GrampsLocale(object):
key = locale.strxfrm(string) key = locale.strxfrm(string)
locale.setlocale(locale.LC_COLLATE, base_locale) locale.setlocale(locale.LC_COLLATE, base_locale)
except Exception as err:
LOG.warn("Failed to obtain key for %s because %s",
self.collation, str(err))
return string
return key return key
def strcoll(self, string1, string2): def strcoll(self, string1, string2):