diff --git a/aqt/__init__.py b/aqt/__init__.py index 440f03030..76e24bcbd 100644 --- a/aqt/__init__.py +++ b/aqt/__init__.py @@ -1,10 +1,15 @@ # Copyright: Damien Elmes # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import getpass +import os +import sys +import optparse +import tempfile +import __builtin__ +import locale +import gettext -import os, sys, optparse, atexit, tempfile, __builtin__ from aqt.qt import * -import locale, gettext import anki.lang from anki.consts import HELP_SITE from anki.lang import langDir @@ -157,6 +162,7 @@ class AnkiApp(QApplication): sys.stderr.write(sock.errorString()) return buf = sock.readAll() + buf = unicode(buf, sys.getfilesystemencoding(), "ignore") self.emit(SIGNAL("appMsg"), buf) sock.disconnectFromServer() diff --git a/aqt/main.py b/aqt/main.py index 4a705033d..2bc2d3322 100644 --- a/aqt/main.py +++ b/aqt/main.py @@ -64,7 +64,7 @@ class AnkiQt(QMainWindow): "syncing and add-on loading.")) # were we given a file to import? if args and args[0]: - self.onAppMsg(unicode(args[0], "utf8", "ignore")) + self.onAppMsg(unicode(args[0], sys.getfilesystemencoding(), "ignore")) # Load profile in a timer so we can let the window finish init and not # close on profile load error. self.progress.timer(10, self.setupProfile, False) @@ -1113,10 +1113,6 @@ will be lost. Continue?""")) self.connect(self.app, SIGNAL("appMsg"), self.onAppMsg) def onAppMsg(self, buf): - if not isinstance(buf, unicode): - # even though we're sending this as unicode up above, - # a bug report still came in that we were receiving a qbytearray - buf = unicode(buf, "utf8", "ignore") if self.state == "startup": # try again in a second return self.progress.timer(1000, lambda: self.onAppMsg(buf), False)