Skip to content

Commit

Permalink
correctly close files executed from QgsPythonRunner
Browse files Browse the repository at this point in the history
  • Loading branch information
volaya committed Mar 18, 2019
1 parent 4e5888d commit 4a36874
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/app/main.cpp
Expand Up @@ -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 ) );
}

/////////////////////////////////`////////////////////////////////////
Expand Down

0 comments on commit 4a36874

Please sign in to comment.