FamilyGroup Report crash

Python's sort routine gratuitously converts the bytearrays returned by
ICU::Collator::getByteArray to a string when storing it. This resulted
in a TypeError when attempting to compare a just-returned bytearray
with a stored string.

We work around this by converting the bytearray into its hexadecimal
representation and then decoding that into a string.

Fixes #10077.
This commit is contained in:
John Ralls 2017-06-27 11:30:00 -07:00
parent 5972477550
commit ae6db43fc4

View File

@ -32,6 +32,7 @@ import codecs
import locale
import collections
import logging
from binascii import hexlify
LOG = logging.getLogger("." + __name__)
LOG.propagate = True
@ -856,8 +857,9 @@ class GrampsLocale(object):
"""
if HAVE_ICU and self.collator:
#ICU can digest strings and unicode
return self.collator.getCollationKey(string).getByteArray()
# ICU can digest strings and unicode
# Use hexlify() as to make a consistent string, fixing bug #10077
return hexlify(self.collator.getCollationKey(string).getByteArray()).decode()
else:
if isinstance(string, bytes):
string = string.decode("utf-8", "replace")