[Libreoffice-commits] core.git: solenv/bin

Mike Kaganski (via logerrit) logerrit at kemper.freedesktop.org
Tue Sep 15 10:30:45 UTC 2020


 solenv/bin/image-sort.py |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

New commits:
commit c4d9e922eefd08382e7a4f9fb1926f82a3f8fc4d
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Tue Sep 15 10:42:16 2020 +0200
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Tue Sep 15 12:30:09 2020 +0200

    Don't use argparse to open control_file
    
    Use idiomatic 'with' instead
    This avoids the warnings:
    
      Exception ignored in: <_io.FileIO name='C:/lo/src/core/postprocess/packimages/image-sort.lst' mode='rb' closefd=True>
      ResourceWarning: unclosed file <_io.TextIOWrapper name='C:/lo/src/core/postprocess/packimages/image-sort.lst' mode='r' encoding='cp1251'>
    
    Change-Id: I1cf8248cdab8dd9fd585545c64de2aebcbfe5365
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102647
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/solenv/bin/image-sort.py b/solenv/bin/image-sort.py
index d45037e25c7f..75b5da6ce0e7 100644
--- a/solenv/bin/image-sort.py
+++ b/solenv/bin/image-sort.py
@@ -120,7 +120,7 @@ def chew_controlfile(ifile):
 
 parser = argparse.ArgumentParser()
 # where the control file lives
-parser.add_argument('control_file', metavar='image-sort.lst', type=open,
+parser.add_argument('control_file', metavar='image-sort.lst',
                     help='the sort control file')
 # where the uiconfigs live
 parser.add_argument('base_path', metavar='directory',
@@ -138,7 +138,8 @@ else:
     args.output = sys.stdout
     close_output = False
 
-chew_controlfile(args.control_file)
+with open(args.control_file) as cf:
+    chew_controlfile(cf)
 
 for icon in global_list:
     if not icon.startswith('sc_'):


More information about the Libreoffice-commits mailing list