commit 33700532b72d304bcb4caa47a55b8d665aa92a00 Author: Marco Miller Date: Wed Oct 14 12:56:17 2020 -0400 Replace unguaranteed file closing with 'with' statement in release_noter As this will automatically close the open file no matter what; cf. [1]. [1] https://www.python.org/dev/peps/pep-0343 Change-Id: I1f8ce004763917014f23bb168fa63d954df56c13 diff --git a/tools/release_noter/release_noter.py b/tools/release_noter/release_noter.py index eb00d5d..2702764 100644 --- a/tools/release_noter/release_noter.py +++ b/tools/release_noter/release_noter.py @@ -268,11 +268,10 @@ def print_submodules(submodules, md): def print_notes(commits, submodules): - md = open("release_noter.md", "w") - md.write("# Release Notes\n") - print_submodules(submodules, md) - print_commits(commits, md) - md.close() + with open("release_noter.md", "w") as md: + md.write("# Release Notes\n") + print_submodules(submodules, md) + print_commits(commits, md) if __name__ == "__main__":