Skip to content

Commit ab1f31e

Browse files
committed
Fix #15215 (misra.py: analyse_ctu_info() does not close the ctu-info files)
Close the ctu-info files after reading them. The files were only closed by the garbage collector, which gives a ResourceWarning.
1 parent 7b481f4 commit ab1f31e

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎addons/misra.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4912,9 +4912,13 @@ def is_different_location(loc1, loc2):
49124912
def is_different_file(loc1, loc2):
49134913
return loc1['file'] != loc2['file']
49144914

4915+
def read_lines(filename):
4916+
with open(filename, 'rt') as f:
4917+
yield from f
4918+
49154919
try:
49164920
for filename in ctu_info_files:
4917-
for line in open(filename, 'rt'):
4921+
for line in read_lines(filename):
49184922
s = self.read_ctu_info_line(line)
49194923
if s is None:
49204924
continue

0 commit comments

Comments
 (0)