From 4a36874586813497845c23a22361fc29493a0514 Mon Sep 17 00:00:00 2001 From: volaya Date: Mon, 18 Mar 2019 07:27:22 +0000 Subject: [PATCH] correctly close files executed from QgsPythonRunner --- src/app/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 ) ); } /////////////////////////////////`////////////////////////////////////