diff --git a/gramps/gui/clipboard.py b/gramps/gui/clipboard.py index 303fd3880..3053b590b 100644 --- a/gramps/gui/clipboard.py +++ b/gramps/gui/clipboard.py @@ -209,6 +209,10 @@ class ClipWrapper(object): return self._dbname def pack(self): + """ + Return a byte string that can be packed in a GtkSelectionData + structure + """ if not self.is_valid(): data = list(pickle.loads(self._pickle)) data[2] = { @@ -224,12 +228,19 @@ class ClipWrapper(object): } return pickle.dumps(data) else: - return str(self._obj) + if sys.version_info[0] < 3: + return str(self._obj) + else: + if isinstance(self._obj, bytes): + return self._obj + else: + ## don't know if this happens in Gramps, theoretically possible + asuni = str(self._obj) + return asuni.encode('utf-8') def is_valid(self): return True - class ClipHandleWrapper(ClipWrapper): def __init__(self,dbstate, obj):