param: Fix resource leak
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Wed, 19 Apr 2023 21:20:38 +0000 (09:20 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 5 May 2023 02:54:31 +0000 (02:54 +0000)
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
script/generate_param.py

index 4a4f7fec878a6a25e99a81ae249be5d009a4cc5d..50f2d12599ac760bd5ea70a2a6c0f9fcb6e81e41 100644 (file)
@@ -51,10 +51,10 @@ def iterate_all(path):
     """
 
     try:
-        p = open(path, 'r')
+        with open(path, 'r') as p:
+            out = p.read()
     except IOError as e:
         raise Exception("Error opening parameters file")
-    out = p.read()
 
     # parse the parameters xml file
     root = ET.fromstring(out)