createmsi: retrieve file handle explicitely so we can close it at the end

Seen on https://ci.libreoffice.org/view/tb%20platform%20status/job/lo_daily_tb_win_wix/3/console
[build PRL] CustomTarget/instsetoo_native/install/install.phony
Exception ignored in: <_io.FileIO name='lo.json' mode='rb' closefd=True>
Traceback (most recent call last):
  File "C:\cygwin64\home\tdf\jenkins\daily_workspace\tb\src_master\msicreator\createmsi.py", line 42, in __init__
    jsondata = json.load(open(jsonfile, 'rb'))
ResourceWarning: unclosed file <_io.BufferedReader name='lo.json'>

Change-Id: I98b7436e4e870f4cbcd31a41a4e9d0e84249f5f9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159566
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
Julien Nabet 2023-11-17 13:21:17 +01:00 committed by Mike Kaganski
parent 533e993f2d
commit 39f83d3dc2

View file

@ -39,7 +39,8 @@ class UIGraphics:
class PackageGenerator:
def __init__(self, jsonfile):
jsondata = json.load(open(jsonfile, 'rb'))
with open(jsonfile, 'rb') as f:
jsondata = json.load(f)
self.product_name = jsondata['product_name']
self.manufacturer = jsondata['manufacturer']
self.version = jsondata['version']