[dataimport] fix SQLGenObjectStore's add_info for python3
authorJulien Cristau <julien.cristau@logilab.fr>
Mon, 21 Dec 2015 15:44:20 +0100
changeset 11010 09be4709c8c0
parent 11009 d5962fb5bb8e
child 11011 94bbf6d7eaf8
[dataimport] fix SQLGenObjectStore's add_info for python3
dataimport/pgstore.py
--- a/dataimport/pgstore.py	Mon Dec 21 15:43:49 2015 +0100
+++ b/dataimport/pgstore.py	Mon Dec 21 15:44:20 2015 +0100
@@ -26,7 +26,7 @@
 from collections import defaultdict
 from base64 import b64encode
 
-from six import string_types, integer_types, text_type
+from six import string_types, integer_types, text_type, binary_type
 from six.moves import cPickle as pickle, range
 
 from cubicweb.utils import make_uid
@@ -419,8 +419,8 @@
         """add type and source info for an eid into the system table"""
         # begin by inserting eid/type/source/extid into the entities table
         if extid is not None:
-            assert isinstance(extid, str)
-            extid = b64encode(extid)
+            assert isinstance(extid, binary_type)
+            extid = b64encode(extid).decode('ascii')
         attrs = {'type': entity.cw_etype, 'eid': entity.eid, 'extid': extid,
                  'asource': source.uri}
         self._handle_insert_entity_sql(cnx, self.sqlgen.insert('entities', attrs), attrs)