summaryrefslogtreecommitdiffstats
path: root/BaseTools/Source/Python/AutoGen/InfSectionParser.py
diff options
context:
space:
mode:
authormjohn4 <michael.johnson@intel.com>2018-11-02 10:02:10 +0800
committerFeng, Bob C <bob.c.feng@intel.com>2019-03-15 15:38:59 +0800
commitb0189eac00a5a97ecf4697bfe22d49aa47e39162 (patch)
treebad2bb1df7ad62eb9ac6d7c1399f3af12fa5f833 /BaseTools/Source/Python/AutoGen/InfSectionParser.py
parentdbe05cb1c0386b6c6abc32b771499acc28a27520 (diff)
downloadedk2-b0189eac00a5a97ecf4697bfe22d49aa47e39162.tar.gz
edk2-b0189eac00a5a97ecf4697bfe22d49aa47e39162.tar.bz2
edk2-b0189eac00a5a97ecf4697bfe22d49aa47e39162.zip
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 <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Michael Johnson <michael.johnson@intel.com> Reviewed-by: Bob Feng <bob.c.feng@intel.com>
Diffstat (limited to 'BaseTools/Source/Python/AutoGen/InfSectionParser.py')
-rw-r--r--BaseTools/Source/Python/AutoGen/InfSectionParser.py3
1 files changed, 2 insertions, 1 deletions
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)