From 4c7f7a7c4bf78a0610e7cb7112798fb51ead6246 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 14 Jun 2012 08:41:19 +0900 Subject: [PATCH] make sure we pass filename as utf8 to sqlite --- anki/upgrade.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/anki/upgrade.py b/anki/upgrade.py index 09c8938e5..874a8dfe3 100644 --- a/anki/upgrade.py +++ b/anki/upgrade.py @@ -37,7 +37,7 @@ class Upgrader(object): def check(self, path): "True if deck looks ok." - with DB(path) as db: + with DB(self._utf8(path)) as db: return self._check(db) def _check(self, db): @@ -111,12 +111,17 @@ f.id = cards.factId)"""): def _openDB(self, path): self.tmppath = tmpfile(suffix=".anki2") - shutil.copy(path, self.tmppath) + shutil.copy(path, self._utf8(self.tmppath)) self.db = DB(self.tmppath) def _openCol(self): self.col = _Collection(self.db) + def _utf8(self, txt): + if isinstance(txt, unicode): + return txt.encode("utf8") + return txt + # Schema upgrade ######################################################################