diff sat/memory/sqlite.py @ 3551:0ce37cf3fbf4

memory(sqlite): fix encoding when loading pickled data
author Goffi <goffi@goffi.org>
date Wed, 09 Jun 2021 10:01:56 +0200
parents 31cbcdd096a2
children
line wrap: on
line diff
--- a/sat/memory/sqlite.py	Sun Jun 06 22:06:28 2021 +0200
+++ b/sat/memory/sqlite.py	Wed Jun 09 10:01:56 2021 +0200
@@ -706,12 +706,12 @@
             msg = failure_))
 
     def _load_pickle(self, v):
-        # FIXME: workaround for Python 3 port, some pickled data are byte while other are strings
+        # FIXME: workaround for Python 3 port, some pickled data are bytes while other are strings
         try:
-            return pickle.loads(v)
+            return pickle.loads(v, encoding="utf-8")
         except TypeError:
-            data = pickle.loads(v.encode('utf-8'))
-            log.warning(f"encoding issue in pickled data: {data}")
+            data = pickle.loads(v.encode('utf-8'), encoding="utf-8")
+            log.debug(f"encoding issue in pickled data: {data}")
             return data
 
     def _generateDataDict(self, query_result, binary):