7471: Fix python3 sort key errors
Ensure input to strxfrm is correct type. Apply patch by Marc Hulsman.
This commit is contained in:
parent
c8df231cd7
commit
3880914e96
@ -852,12 +852,12 @@ class GrampsLocale(object):
|
||||
#ICU can digest strings and unicode
|
||||
return self.collator.getCollationKey(string).getByteArray()
|
||||
else:
|
||||
if sys.version_info[0] < 3 and isinstance(string, unicode):
|
||||
string = string.encode("utf-8", "replace")
|
||||
if sys.version_info[0] >= 3 and isinstance(string, bytes):
|
||||
string = string.decode("utf-8", "replace")
|
||||
try:
|
||||
if sys.version_info[0] < 3 and isinstance(string, unicode):
|
||||
key = locale.strxfrm(string.encode("utf-8", "replace"))
|
||||
else:
|
||||
key = locale.strxfrm(string)
|
||||
|
||||
key = locale.strxfrm(string)
|
||||
except Exception as err:
|
||||
LOG.warn("Failed to obtain key for %s because %s",
|
||||
self.collation, str(err))
|
||||
|
@ -92,10 +92,10 @@ class Node(object):
|
||||
#sortkey must be localized sort, so
|
||||
self.sortkey = glocale.sort_key(sortkey)
|
||||
if not self.sortkey:
|
||||
self.sortkey = b''
|
||||
self.sortkey = glocale.sort_key('')
|
||||
else:
|
||||
self.name = ''
|
||||
self.sortkey = b''
|
||||
self.sortkey = glocale.sort_key('')
|
||||
self.ref = ref
|
||||
self.handle = handle
|
||||
self.secondary = secondary
|
||||
|
Loading…
Reference in New Issue
Block a user