diff src/memory/sqlite.py @ 839:f8681a7fd834

memory (sqlite): the result of pickle.dumps in addToHistory must be encoded for the special characters to be stored.
author souliane <souliane@mailoo.org>
date Wed, 12 Feb 2014 21:46:48 +0100
parents 1fe00f0c9a91
children c2f6ada7858f
line wrap: on
line diff
--- a/src/memory/sqlite.py	Wed Feb 12 15:24:03 2014 +0100
+++ b/src/memory/sqlite.py	Wed Feb 12 21:46:48 2014 +0100
@@ -190,9 +190,10 @@
         assert(profile)
         if extra is None:
             extra = {}
+        extra_ = pickle.dumps({k: v.encode('utf-8') for k, v in extra.items()}, 0).decode('utf-8')
         d = self.dbpool.runQuery("INSERT INTO history(source, source_res, dest, dest_res, timestamp, message, type, extra, profile_id) VALUES (?,?,?,?,?,?,?,?,?)",
                                  (from_jid.userhost(), from_jid.resource, to_jid.userhost(), to_jid.resource, timestamp or time(),
-                                  message, _type, pickle.dumps(extra, 0), self.profiles[profile]))
+                                  message, _type, extra_, self.profiles[profile]))
         d.addErrback(lambda ignore: error(_("Can't save following message in history: from [%(from_jid)s] to [%(to_jid)s] ==> [%(message)s]" %
                                           {"from_jid": from_jid.full(), "to_jid": to_jid.full(), "message": message})))
         return d