From a4abc9f26a7196259a456ad081100445551064b2 Mon Sep 17 00:00:00 2001 From: Benny Malengier Date: Fri, 11 Jan 2013 17:20:00 +0000 Subject: [PATCH] fix error from fix encoding issue for python 3 svn: r21069 --- gramps/gen/db/read.py | 11 +++++++++++ gramps/gen/db/write.py | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) 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),