From 5b0671c1e514e534c6d5be9604da33bfc2cd0a24 Mon Sep 17 00:00:00 2001 From: Gary Lin Date: Mon, 25 Jun 2018 18:31:25 +0800 Subject: BaseTools: Refactor python except statements Convert "except ... ," to "except ... as" to be compatible with python3. Based on "futurize -f lib2to3.fixes.fix_except" Contributed-under: TianoCore Contribution Agreement 1.1 Cc: Yonghong Zhu Cc: Liming Gao Signed-off-by: Gary Lin Reviewed-by: Yonghong Zhu --- BaseTools/Source/Python/Workspace/MetaFileParser.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'BaseTools/Source/Python/Workspace/MetaFileParser.py') diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py index 88c7bb374c..f1cfa73fd4 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -1341,7 +1341,7 @@ class DscParser(MetaFileParser): self._InSubsection = False try: Processer[self._ItemType]() - except EvaluationException, Excpt: + except EvaluationException as Excpt: # # Only catch expression evaluation error here. We need to report # the precise number of line on which the error occurred @@ -1363,7 +1363,7 @@ class DscParser(MetaFileParser): EdkLogger.error('Parser', FORMAT_INVALID, "Invalid expression: %s" % str(Excpt), File=self._FileWithError, ExtraData=' '.join(self._ValueList), Line=self._LineIndex + 1) - except MacroException, Excpt: + except MacroException as Excpt: EdkLogger.error('Parser', FORMAT_INVALID, str(Excpt), File=self._FileWithError, ExtraData=' '.join(self._ValueList), Line=self._LineIndex + 1) @@ -1465,10 +1465,10 @@ class DscParser(MetaFileParser): Macros.update(GlobalData.gGlobalDefines) try: Result = ValueExpression(self._ValueList[1], Macros)() - except SymbolNotFound, Exc: + except SymbolNotFound as Exc: EdkLogger.debug(EdkLogger.DEBUG_5, str(Exc), self._ValueList[1]) Result = False - except WrnExpression, Excpt: + except WrnExpression as Excpt: # # Catch expression evaluation warning here. We need to report # the precise number of line and return the evaluation result @@ -1614,7 +1614,7 @@ class DscParser(MetaFileParser): if PcdValue and "." not in self._ValueList[0]: try: ValList[Index] = ValueExpression(PcdValue, self._Macros)(True) - except WrnExpression, Value: + except WrnExpression as Value: ValList[Index] = Value.result except: pass @@ -2019,7 +2019,7 @@ class DecParser(MetaFileParser): try: self._GuidDict.update(self._AllPcdDict) ValueList[0] = ValueExpressionEx(ValueList[0], ValueList[1], self._GuidDict)(True) - except BadExpression, Value: + except BadExpression as Value: EdkLogger.error('Parser', FORMAT_INVALID, Value, ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1) # check format of default value against the datum type IsValid, Cause = CheckPcdDatum(ValueList[1], ValueList[0]) -- cgit v1.2.3