py/gadict_srs_anki.py
changeset 1008 dc218f2b784d
parent 931 9a5f97027ee7
child 1215 d7394ed6693d
--- a/py/gadict_srs_anki.py	Wed Jan 31 00:27:20 2018 +0200
+++ b/py/gadict_srs_anki.py	Fri Feb 09 15:05:35 2018 +0200
@@ -222,7 +222,7 @@
         deck_id = collection.decks.id(self.name)
 
         # It is essential to keep model['id'] unchanged between upgrades!!
-        model_id = int(hashlib.sha1(self.name).hexdigest(), 16) % (2**63)
+        model_id = int(hashlib.sha1(self.name.encode('utf-8')).hexdigest(), 16) % (2**63)
 
         ################################################################
         # Regular card model. SafeBack doesn't include examples to not spoil
@@ -340,9 +340,9 @@
         :unambiguous  used if several subsequent article with same headword (and different pronunciation)
         """
         if unambiguous > 0:
-            h = hashlib.md5(":".join((self.name, nodetype, headword, str(unambiguous))))
+            h = hashlib.md5(":".join((self.name, nodetype, headword, str(unambiguous))).encode('utf-8'))
         else:
-            h = hashlib.md5(":".join((self.name, nodetype, headword)))
+            h = hashlib.md5(":".join((self.name, nodetype, headword)).encode('utf-8'))
         return h.hexdigest()
 
     def add_note(self, headword, unambiguous, front, back, safeback, freq="", tags=None):