From ebf51f227c3daef1a8558f63ed3fea9fa9a96398 Mon Sep 17 00:00:00 2001 From: "Tanjeff-N. Moos" Date: Sun, 31 Jul 2022 16:22:56 +0200 Subject: [PATCH] sconsDoxy: Restructure code: close file in case of exception. Up to now, the file was opened, then DoxyfileParse() was invoked, then the file was closed. If DoxyfileParse() throws an exception, the file would not be closed. The new solution auto-closes the file in any case. --- doxygen.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/doxygen.py b/doxygen.py index 579b77cf8..5a1e46ca2 100644 --- a/doxygen.py +++ b/doxygen.py @@ -107,9 +107,8 @@ def DoxyfileParse(file_contents, conf_dir, data=None): if nextfile in data[key]: raise Exception("recursive @INCLUDE in Doxygen config: " + nextfile) data[key].append(nextfile) - fh = open(nextfile, "r") - DoxyfileParse(fh.read(), conf_dir, data) - fh.close() + with open(nextfile, "r") as fh: + DoxyfileParse(fh.read(), conf_dir, data) else: append_data(data, key, new_data, token) new_data = True