Skip to content

Commit

Permalink
Fix error when executing python code under python 3
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Sep 5, 2016
1 parent 0ead08b commit fd0d804
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion python/console/console_editor.py
Expand Up @@ -594,7 +594,7 @@ def runScriptCode(self):
tmpFile = self.createTempFile()
filename = tmpFile

self.parent.pc.shell.runCommand(u"execfile(u'{0}'.encode('{1}'))"
self.parent.pc.shell.runCommand(u"exec(open(u'{0}'.encode('{1}')).read())"
.format(filename.replace("\\", "/"), sys.getfilesystemencoding()))

def runSelectedCode(self):
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgisapp.cpp
Expand Up @@ -5145,7 +5145,7 @@ void QgisApp::runScript( const QString &filePath )

mPythonUtils->runString(
QString( "import sys\n"
"execfile(\"%1\".replace(\"\\\\\", \"/\").encode(sys.getfilesystemencoding()))\n" ).arg( filePath )
"exec(open(\"%1\".replace(\"\\\\\", \"/\").encode(sys.getfilesystemencoding())).read())\n" ).arg( filePath )
, tr( "Failed to run Python script:" ), false );
}

Expand Down

0 comments on commit fd0d804

Please sign in to comment.