Cleanup: use context-manager for opening files

This commit is contained in:
Campbell Barton
2025-01-04 22:26:18 +11:00
parent 0f1e1bcdae
commit c5203ef7fd
4 changed files with 19 additions and 24 deletions

View File

@@ -234,9 +234,8 @@ def cmake_compiler_defines() -> list[str] | None:
os.system("%s -dM -E %s > %s" % (compiler, temp_c, temp_def))
temp_def_file = open(temp_def)
lines = [l.strip() for l in temp_def_file if l.strip()]
temp_def_file.close()
with open(temp_def) as temp_def_fh:
lines = [l.strip() for l in temp_def_fh if l.strip()]
os.remove(temp_c)
os.remove(temp_def)