Skip to content

Commit a8078a2

Browse files
volayanyalldawson
authored andcommitted
correctly close files executed from QgsPythonRunner
1 parent 1b79513 commit a8078a2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/app/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1387,7 +1387,7 @@ int main( int argc, char *argv[] )
13871387
//replace backslashes with forward slashes
13881388
pythonfile.replace( '\\', '/' );
13891389
#endif
1390-
QgsPythonRunner::run( QStringLiteral( "exec(open('%1').read())" ).arg( pythonfile ) );
1390+
QgsPythonRunner::run( QStringLiteral( "with open('%1','r') as f: exec(f.read())" ).arg( pythonfile ) );
13911391
}
13921392

13931393
/////////////////////////////////`////////////////////////////////////

0 commit comments

Comments
 (0)