diff --git a/src/app/main.cpp b/src/app/main.cpp index 4f7d4799034..5c0aaa1b7e3 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -1390,7 +1390,7 @@ int main( int argc, char *argv[] ) //replace backslashes with forward slashes pythonfile.replace( '\\', '/' ); #endif - QgsPythonRunner::run( QStringLiteral( "exec(open('%1').read())" ).arg( pythonfile ) ); + QgsPythonRunner::run( QStringLiteral( "with open('%1','r') as f: exec(f.read())" ).arg( pythonfile ) ); } /////////////////////////////////`////////////////////////////////////