diff --git a/gramps/gen/db/read.py b/gramps/gen/db/read.py index e9fe01f0d..dd2ee2291 100644 --- a/gramps/gen/db/read.py +++ b/gramps/gen/db/read.py @@ -102,6 +102,17 @@ DBERRS = (db.DBRunRecoveryError, db.DBAccessError, # Helper functions # #------------------------------------------------------------------------- +def find_byte_surname(key, data): + """ + Creating a surname from raw data of a person, to use for sort and index + returns a byte string + """ + surn = __index_surname(data[3][5]) + # in python 3 we work with unicode internally, but need byte function sometimes + if isinstance(surn, UNITYPE): + return surn.encode('utf-8') + return surn + def find_surname(key, data): """ Creating a surname from raw data of a person, to use for sort and index diff --git a/gramps/gen/db/write.py b/gramps/gen/db/write.py index c1f2976c0..0b0eb8882 100644 --- a/gramps/gen/db/write.py +++ b/gramps/gen/db/write.py @@ -74,7 +74,7 @@ from ..lib.researcher import Researcher from . import (DbBsddbRead, DbWriteBase, BSDDBTxn, DbTxn, BsddbBaseCursor, BsddbDowngradeError, DbVersionError, DbEnvironmentError, DbUpgradeRequiredError, find_surname, - find_surname_name, DbUndoBSDDB as DbUndo) + find_byte_surname, find_surname_name, DbUndoBSDDB as DbUndo) from .dbconst import * from ..utils.callback import Callback from ..utils.cast import (conv_unicode_tosrtkey, conv_dbstr_to_unicode) @@ -718,7 +718,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback): if not self.readonly: assoc = [ - (self.person_map, self.surnames, find_surname), + (self.person_map, self.surnames, find_byte_surname), (self.person_map, self.id_trans, find_idmap), (self.family_map, self.fid_trans, find_idmap), (self.event_map, self.eid_trans, find_idmap),