From ab1f31e07c8161e9b69ae72dd91bab08567dca0b Mon Sep 17 00:00:00 2001 From: Guillaume Chauvel Date: Tue, 3 Nov 2026 21:39:04 +0100 Subject: [PATCH] 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. --- addons/misra.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/misra.py b/addons/misra.py index 7c7774c52e3..dddb2e2602f 100755 --- a/addons/misra.py +++ b/addons/misra.py @@ -4912,9 +4912,13 @@ def is_different_location(loc1, loc2): def is_different_file(loc1, loc2): return loc1['file'] != loc2['file'] + def read_lines(filename): + with open(filename, 'rt') as f: + yield from f + try: for filename in ctu_info_files: - for line in open(filename, 'rt'): + for line in read_lines(filename): s = self.read_ctu_info_line(line) if s is None: continue