From ae6db43fc48dcd003d6df4afe2545ab7ae441f66 Mon Sep 17 00:00:00 2001 From: John Ralls Date: Tue, 27 Jun 2017 11:30:00 -0700 Subject: [PATCH] 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. --- gramps/gen/utils/grampslocale.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gramps/gen/utils/grampslocale.py b/gramps/gen/utils/grampslocale.py index 91b18d1a6..3458be1be 100644 --- a/gramps/gen/utils/grampslocale.py +++ b/gramps/gen/utils/grampslocale.py @@ -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")