Fix #320: argv is str but our filenames must be unicode

TODO: figure out why argparse sometimes gets the exe as a filename
This commit is contained in:
David Vierra 2017-06-14 20:46:14 -10:00
parent 39add23d5f
commit 59f3c0bb92
2 changed files with 7 additions and 0 deletions

View File

@ -487,12 +487,18 @@ class MCEditApp(QtGui.QApplication):
for filename in self.args.filename:
try:
# we use `unicode` filenames, but argv is `str`
# should only get `str` on linux/osx - need to get wargv on windows
if isinstance(filename, str):
filename = filename.decode(sys.getfilesystemencoding())
if os.path.exists(filename):
self.commandLineWorlds.append(filename)
else:
log.info("File not found: %s", filename)
except EnvironmentError as e:
log.info("%r", e)
except UnicodeDecodeError as e:
log.info("%r", e)
# --- Language Menu ---

View File

@ -187,6 +187,7 @@ def startup():
from mcedit2 import support_modules
# TODO: get wchar_t argv from windows
editorApp = MCEditApp(sys.argv)
editorApp.startup()