From 7a884ab6a59a777d1e22efd58194c649e05ee02e Mon Sep 17 00:00:00 2001 From: Diego Barrios Romero Date: Mon, 29 Oct 2018 10:54:50 +0100 Subject: [PATCH] Fix closing input file --- modules/python/src2/gen2.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/python/src2/gen2.py b/modules/python/src2/gen2.py index 6995e23651..d8bce41ff3 100755 --- a/modules/python/src2/gen2.py +++ b/modules/python/src2/gen2.py @@ -1091,6 +1091,7 @@ if __name__ == "__main__": if len(sys.argv) > 1: dstdir = sys.argv[1] if len(sys.argv) > 2: - srcfiles = [f.strip() for f in open(sys.argv[2], 'r').readlines()] + with open(sys.argv[2], 'r') as f: + srcfiles = [l.strip() for l in f.readlines()] generator = PythonWrapperGenerator() generator.gen(srcfiles, dstdir)