[Libreoffice-commits] core.git: pyuno/source
Mike Kaganski (via logerrit)
logerrit at kemper.freedesktop.org
Mon Dec 7 07:15:36 UTC 2020
pyuno/source/loader/pythonloader.py | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
New commits:
commit 3e524922b93b1fe811d3b20f8f6cdf01461348ac
Author: Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Mon Dec 7 09:09:24 2020 +0300
Commit: Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Mon Dec 7 08:14:46 2020 +0100
Wrap "open" into "with"
Change-Id: I1ecc16ddf565ac1f7306289fd51b673ed928cc20
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107329
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
diff --git a/pyuno/source/loader/pythonloader.py b/pyuno/source/loader/pythonloader.py
index 7c16e226bad9..9a7114aea210 100644
--- a/pyuno/source/loader/pythonloader.py
+++ b/pyuno/source/loader/pythonloader.py
@@ -90,17 +90,16 @@ class Loader( XImplementationLoader, XServiceInfo, unohelper.Base ):
# read the file
filename = unohelper.fileUrlToSystemPath( url )
- fileHandle = open( filename, encoding='utf_8' )
- src = fileHandle.read().replace("\r","")
- if not src.endswith( "\n" ):
- src = src + "\n"
-
- # compile and execute the module
- codeobject = compile( src, encfile(filename), "exec" )
- mod.__file__ = filename
- exec(codeobject, mod.__dict__)
- g_loadedComponents[url] = mod
- fileHandle.close()
+ with open( filename, encoding='utf_8' ) as fileHandle:
+ src = fileHandle.read().replace("\r","")
+ if not src.endswith( "\n" ):
+ src = src + "\n"
+
+ # compile and execute the module
+ codeobject = compile( src, encfile(filename), "exec" )
+ mod.__file__ = filename
+ exec(codeobject, mod.__dict__)
+ g_loadedComponents[url] = mod
return mod
elif "vnd.openoffice.pymodule" == protocol:
nSlash = dependent.rfind('/')
More information about the Libreoffice-commits
mailing list