Since GTK3, unicode and str must be correctly (de)coded

svn: r19970
This commit is contained in:
Benny Malengier 2012-07-10 12:40:27 +00:00
parent 2ff2f4ff57
commit 4c5470492f

View File

@ -1466,13 +1466,19 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
If not then we need to remove the name from the list. If not then we need to remove the name from the list.
The function must be overridden in the derived class. The function must be overridden in the derived class.
""" """
name = str(find_surname_name(person.handle, name = find_surname_name(person.handle,
person.get_primary_name().serialize())) person.get_primary_name().serialize())
if isinstance(name, unicode):
uname = name
name = str(name)
else:
uname = unicode(name, 'utf-8')
try: try:
cursor = self.surnames.cursor(txn=self.txn) cursor = self.surnames.cursor(txn=self.txn)
cursor_position = cursor.set(name) cursor_position = cursor.set(name)
if cursor_position is not None and cursor.count() == 1: if cursor_position is not None and cursor.count() == 1:
i = bisect.bisect(self.surname_list, name) #surname list contains unicode objects
i = bisect.bisect(self.surname_list, uname)
if 0 <= i-1 < len(self.surname_list): if 0 <= i-1 < len(self.surname_list):
del self.surname_list[i-1] del self.surname_list[i-1]
except db.DBError, err: except db.DBError, err: