Skip to content
Permalink
Browse files

Fix error when executing python code under python 3

  • Loading branch information
nyalldawson committed Sep 5, 2016
1 parent 0ead08b commit fd0d8043413fde25f97fd114b7ff512137fac56e
Showing with 2 additions and 2 deletions.
  1. +1 −1 python/console/console_editor.py
  2. +1 −1 src/app/qgisapp.cpp
@@ -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):
@@ -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 );
}

0 comments on commit fd0d804

Please sign in to comment.
You can’t perform that action at this time.