7471: Fix python3 sort key errors
Ensure input to strxfrm is correct type. Apply patch by Marc Hulsman.
This commit is contained in:
parent
ccd6c3143e
commit
baf368c049
@ -862,12 +862,12 @@ class GrampsLocale(object):
|
||||
#ICU can digest strings and unicode
|
||||
return self.collator.getCollationKey(string).getByteArray()
|
||||
else:
|
||||
try:
|
||||
if sys.version_info[0] < 3 and isinstance(string, unicode):
|
||||
key = locale.strxfrm(string.encode("utf-8", "replace"))
|
||||
else:
|
||||
string = string.encode("utf-8", "replace")
|
||||
if sys.version_info[0] >= 3 and isinstance(string, bytes):
|
||||
string = string.decode("utf-8", "replace")
|
||||
try:
|
||||
key = locale.strxfrm(string)
|
||||
|
||||
except Exception as err:
|
||||
LOG.warn("Failed to obtain key for %s because %s",
|
||||
self.collation, str(err))
|
||||
|
@ -90,10 +90,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