diff --git a/src/app/main.cpp b/src/app/main.cpp index 212e63402406..42fa5447b526 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -1386,7 +1386,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 ) ); } /////////////////////////////////`////////////////////////////////////