Skip to content

Commit 0d6b0ce

Browse files
decsnycfriedt
authored andcommitted
scripts: gen_offset_header: Fix file leak
The files should be closed after done being used, otherwise python warnings are generated from the sys module Signed-off-by: Declan Snyder <[email protected]>
1 parent 83b9577 commit 0d6b0ce

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

scripts/build/gen_offset_header.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ def gen_offset_header(input_name, input_file, output_file):
7777

7878
args = parser.parse_args()
7979

80-
input_file = open(args.input, 'rb')
81-
output_file = open(args.output, 'w')
80+
with open(args.input, 'rb') as input_file, open(args.output, 'w') as output_file:
81+
ret = gen_offset_header(args.input, input_file, output_file)
8282

83-
ret = gen_offset_header(args.input, input_file, output_file)
8483
sys.exit(ret)

0 commit comments

Comments
 (0)