diff --git a/gramps/gen/db/read.py b/gramps/gen/db/read.py index 359aeb49a..c0812c874 100644 --- a/gramps/gen/db/read.py +++ b/gramps/gen/db/read.py @@ -215,10 +215,12 @@ class DbBsddbTreeCursor(BsddbBaseCursor): """ Iterator """ - to_do = [''] + _n = self.next_dup + to_do = [b''] while to_do: - data = self.set(str(to_do.pop())) - _n = self.next_dup + key = to_do.pop() + key = key.encode('utf-8') if not isinstance(key, bytes) else key + data = self.set(key) while data: payload = pickle.loads(data[1]) yield (payload[0], payload) diff --git a/gramps/gen/db/upgrade.py b/gramps/gen/db/upgrade.py index 359c8f11b..66da1ad73 100644 --- a/gramps/gen/db/upgrade.py +++ b/gramps/gen/db/upgrade.py @@ -38,7 +38,7 @@ LOG = logging.getLogger(".citation") from ..const import GRAMPS_LOCALE as glocale _ = glocale.translation.gettext -from ..constfunc import cuni, UNITYPE +from ..constfunc import cuni, UNITYPE, handle2internal """ methods to upgrade a database from version 13 to current version @@ -138,7 +138,7 @@ def gramps_upgrade_17(self): if parent_handle is not None: placeref = PlaceRef() - placeref.ref = parent_handle + placeref.ref = handle2internal(parent_handle) placeref_list = [placeref.serialize()] else: placeref_list = [] @@ -274,7 +274,7 @@ def add_place(self, name, level, parent, title): place.set_type(PlaceType(7-level)) if parent is not None: placeref = PlaceRef() - placeref.ref = parent + placeref.ref = handle2internal(parent) place.set_placeref_list([placeref]) with BSDDBTxn(self.env, self.place_map) as txn: if isinstance(handle, UNITYPE): diff --git a/gramps/gen/db/write.py b/gramps/gen/db/write.py index 40f8e9a04..0a919cac6 100644 --- a/gramps/gen/db/write.py +++ b/gramps/gen/db/write.py @@ -1096,7 +1096,8 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback): """ Find all child places having the given place as the primary parent. """ - handle = str(handle) + if isinstance(handle, UNITYPE): + handle = handle.encode('utf-8') parent_cur = self.get_place_parent_cursor() try: diff --git a/gramps/gen/lib/refbase.py b/gramps/gen/lib/refbase.py index d50aab088..d85709462 100644 --- a/gramps/gen/lib/refbase.py +++ b/gramps/gen/lib/refbase.py @@ -61,7 +61,7 @@ class RefBase(object): """ Convert a serialized tuple of data to an object. """ - self.ref = str(data) + self.ref = data return self def get_referenced_handles(self): diff --git a/gramps/plugins/lib/libplaceimport.py b/gramps/plugins/lib/libplaceimport.py index 83d47b134..3551723a8 100644 --- a/gramps/plugins/lib/libplaceimport.py +++ b/gramps/plugins/lib/libplaceimport.py @@ -30,6 +30,7 @@ Helper class for importing places. # #------------------------------------------------------------------------- from gramps.gen.lib import Place, PlaceType, PlaceRef +from gramps.gen.constfunc import handle2internal #------------------------------------------------------------------------- # @@ -89,7 +90,7 @@ class PlaceImport(object): if parent: place = self.db.get_place_from_handle(handle) placeref = PlaceRef() - placeref.ref = parent + placeref.ref = handle2internal(parent) place.set_placeref_list([placeref]) self.db.commit_place(place, trans, place.get_change_time()) @@ -103,7 +104,7 @@ class PlaceImport(object): place.place_type = PlaceType(7-type_num) if parent is not None: placeref = PlaceRef() - placeref.ref = parent + placeref.ref = handle2internal(parent) place.set_placeref_list([placeref]) handle = self.db.add_place(place, trans) self.db.commit_place(place, trans)