diff --git a/aqt/editor.py b/aqt/editor.py index f804e6060..8fd80c6f1 100644 --- a/aqt/editor.py +++ b/aqt/editor.py @@ -779,7 +779,7 @@ to a cloze type first, via Edit>Change Note Type.""")) except Exception, e: showWarning(_( "Couldn't record audio. Have you installed lame and sox?") + - "\n\n" + unicode(e)) + "\n\n" + repr(str(e))) return self.addMedia(file) diff --git a/aqt/importing.py b/aqt/importing.py index f30b55136..c8d22fe58 100644 --- a/aqt/importing.py +++ b/aqt/importing.py @@ -1,13 +1,22 @@ +# coding=utf-8 # Copyright: Damien Elmes # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html -import os, re, traceback, zipfile, json +import os +import re +import traceback +import zipfile +import json + from aqt.qt import * import anki.importing as importing from aqt.utils import getOnlyText, getFile, showText, showWarning, openHelp,\ askUser, tooltip from anki.hooks import addHook, remHook -import aqt.forms, aqt.modelchooser, aqt.deckchooser +import aqt.forms +import aqt.modelchooser +import aqt.deckchooser + class ChangeMap(QDialog): def __init__(self, mw, model, current): @@ -155,7 +164,7 @@ you can enter it here. Use \\t to represent tab."""), return except Exception, e: msg = _("Import failed.\n") - err = unicode(e) + err = repr(str(e)) if "1-character string" in err: msg += err else: @@ -283,7 +292,7 @@ def importFile(mw, file): showUnicodeWarning() return except Exception, e: - msg = unicode(e) + msg = repr(str(e)) if msg == "unknownFormat": if file.endswith(".anki2"): showWarning(_("""\ @@ -322,11 +331,12 @@ failed. Please try again, and if the problem persists, please try again \ with a different browser.""") showWarning(msg) except Exception, e: - if "invalidFile" in unicode(e): + err = repr(str(e)) + if "invalidFile" in err: msg = _("""\ Invalid file. Please restore from backup.""") showWarning(msg) - elif "readonly" in unicode(e): + elif "readonly" in err: showWarning(_("""\ Unable to import from a read-only file.""")) else: diff --git a/aqt/upgrade.py b/aqt/upgrade.py index f9459a398..2a9a6ef28 100644 --- a/aqt/upgrade.py +++ b/aqt/upgrade.py @@ -259,16 +259,16 @@ class UpgradeThread(QThread): try: self.maybeCopyFromCustomFolder(path) except Exception, e: - imp.log.append(unicode(e)) + imp.log.append(repr(str(e))) # then run the import try: imp.run() except Exception, e: - if unicode(e) == "invalidFile": + if repr(str(e)) == "invalidFile": # already logged pass else: - imp.log.append(unicode(e)) + imp.log.append(repr(str(e))) self.col.save() return imp.log