From b0189eac00a5a97ecf4697bfe22d49aa47e39162 Mon Sep 17 00:00:00 2001 From: mjohn4 Date: Fri, 2 Nov 2018 10:02:10 +0800 Subject: BaseTools: Explicitly close files after readlines Rework some file open().readlines to open, readlines, close. This prevents excessive file handles being open at the same time, which may be a problem with alternative python environments. Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Michael Johnson Reviewed-by: Bob Feng --- BaseTools/Source/Python/AutoGen/InfSectionParser.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'BaseTools/Source/Python/AutoGen/InfSectionParser.py') diff --git a/BaseTools/Source/Python/AutoGen/InfSectionParser.py b/BaseTools/Source/Python/AutoGen/InfSectionParser.py index 388b6780df..3337304676 100644 --- a/BaseTools/Source/Python/AutoGen/InfSectionParser.py +++ b/BaseTools/Source/Python/AutoGen/InfSectionParser.py @@ -34,7 +34,8 @@ class InfSectionParser(): SectionData = [] try: - FileLinesList = open(self._FilePath, "r").readlines() + with open(self._FilePath, "r") as File: + FileLinesList = File.readlines() except BaseException: EdkLogger.error("build", AUTOGEN_ERROR, 'File %s is opened failed.' % self._FilePath) -- cgit v1.2.3