[Web] Close stale file handle in exec()

Eliminate the Python interpreter warning about failure to close a stale handle when using the `exec(open('%s').read()` idiom, enclosing it in a `with` clause.
This commit is contained in:
Chris Hennes
2020-12-04 14:58:18 -06:00
committed by wwmayer
parent 9d67962458
commit 39a03ab4e5

View File

@@ -544,7 +544,7 @@ void BrowserView::onLinkClicked (const QUrl & url)
#if PY_MAJOR_VERSION < 3
Gui::Command::doCommand(Gui::Command::Gui,"exec(open(unicode('%s', 'utf-8')).read())",(const char*) filename.toUtf8());
#else
Gui::Command::doCommand(Gui::Command::Gui,"exec(open('%s').read())",(const char*) filename.toUtf8());
Gui::Command::doCommand(Gui::Command::Gui,"with open('%s') as file:\n\texec(file.read())",(const char*) filename.toUtf8());
#endif
}
catch (const Base::Exception& e) {