From nobody Mon Dec 23 17:50:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1516337024599514.4222681587046; Thu, 18 Jan 2018 20:43:44 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id D6E85222DDBEB; Thu, 18 Jan 2018 20:38:20 -0800 (PST) Received: from smtp.nue.novell.com (smtp.nue.novell.com [195.135.221.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 3EE6C2238B597 for ; Thu, 18 Jan 2018 20:38:18 -0800 (PST) Received: from localhost.localdomain (unknown.telstraglobal.net [134.159.103.118]) by smtp.nue.novell.com with ESMTP (NOT encrypted); Fri, 19 Jan 2018 05:43:36 +0100 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=195.135.221.5; helo=smtp.nue.novell.com; envelope-from=glin@suse.com; receiver=edk2-devel@lists.01.org From: Gary Lin To: edk2-devel@lists.01.org Date: Fri, 19 Jan 2018 12:43:02 +0800 Message-Id: <20180119044316.4713-2-glin@suse.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180119044316.4713-1-glin@suse.com> References: <20180119044316.4713-1-glin@suse.com> Subject: [edk2] [PATCH 01/15] BaseTools: Refactor python except statements X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 --- BaseTools/Scripts/UpdateBuildVersions.py | 12 +- BaseTools/Source/Python/AutoGen/AutoGen.py | 10 +- BaseTools/Source/Python/AutoGen/GenDepex.py | 2 +- BaseTools/Source/Python/AutoGen/GenMake.py | 2 +- BaseTools/Source/Python/AutoGen/UniClassObject.py | 4 +- BaseTools/Source/Python/Common/Expression.py | 16 +-- BaseTools/Source/Python/Common/FdfParserLite.py | 6 +- BaseTools/Source/Python/Common/Misc.py | 8 +- BaseTools/Source/Python/Common/RangeExpression.py | 6 +- BaseTools/Source/Python/Common/VpdInfoFile.py | 2 +- BaseTools/Source/Python/Ecc/CParser.py | 142 ++++= ++++++---------- BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaDataTable.py | 2 +- BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py | 14 +- BaseTools/Source/Python/Ecc/Xml/XmlRoutines.py | 2 +- BaseTools/Source/Python/Ecc/c.py | 2 +- BaseTools/Source/Python/Eot/CParser.py | 142 ++++= ++++++---------- BaseTools/Source/Python/Eot/FvImage.py | 2 +- BaseTools/Source/Python/GenFds/FdfParser.py | 10 +- BaseTools/Source/Python/GenFds/GenFds.py | 4 +- BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py | 2 +- BaseTools/Source/Python/TargetTool/TargetTool.py | 2 +- BaseTools/Source/Python/Trim/Trim.py | 4 +- BaseTools/Source/Python/UPT/Core/DependencyRules.py | 4 +- BaseTools/Source/Python/UPT/Core/DistributionPackageClass.py | 4 +- BaseTools/Source/Python/UPT/Core/IpiDb.py | 2 +- BaseTools/Source/Python/UPT/Core/PackageFile.py | 12 +- BaseTools/Source/Python/UPT/InstallPkg.py | 2 +- BaseTools/Source/Python/UPT/InventoryWs.py | 2 +- BaseTools/Source/Python/UPT/Library/CommentParsing.py | 2 +- BaseTools/Source/Python/UPT/Library/ExpressionValidate.py | 8 +- BaseTools/Source/Python/UPT/Library/UniClassObject.py | 8 +- BaseTools/Source/Python/UPT/Library/Xml/XmlRoutines.py | 2 +- BaseTools/Source/Python/UPT/MkPkg.py | 2 +- BaseTools/Source/Python/UPT/ReplacePkg.py | 2 +- BaseTools/Source/Python/UPT/RmPkg.py | 2 +- BaseTools/Source/Python/UPT/TestInstall.py | 4 +- BaseTools/Source/Python/UPT/UPT.py | 4 +- BaseTools/Source/Python/Workspace/DscBuildData.py | 8 +- BaseTools/Source/Python/Workspace/InfBuildData.py | 2 +- BaseTools/Source/Python/Workspace/MetaFileParser.py | 16 +-- BaseTools/Source/Python/Workspace/MetaFileTable.py | 4 +- BaseTools/Source/Python/build/BuildReport.py | 2 +- BaseTools/Source/Python/build/build.py | 10 +- BaseTools/Tests/CheckPythonSyntax.py | 2 +- BaseTools/gcc/mingw-gcc-build.py | 2 +- 45 files changed, 253 insertions(+), 249 deletions(-) diff --git a/BaseTools/Scripts/UpdateBuildVersions.py b/BaseTools/Scripts/U= pdateBuildVersions.py index e62030aa9f0f..cff2e2263a8a 100755 --- a/BaseTools/Scripts/UpdateBuildVersions.py +++ b/BaseTools/Scripts/UpdateBuildVersions.py @@ -90,7 +90,8 @@ def ShellCommandResults(CmdLine, Opt): sys.stderr.flush() returnValue =3D err_val.returncode =20 - except IOError as (errno, strerror): + except IOError as err_arg: + (errno, strerror) =3D err_arg.args file_list.close() if not Opt.silent: sys.stderr.write("I/O ERROR : %s : %s\n" % (str(errno), strerr= or)) @@ -100,7 +101,8 @@ def ShellCommandResults(CmdLine, Opt): sys.stderr.flush() returnValue =3D errno =20 - except OSError as (errno, strerror): + except OSError as err_arg: + (errno, strerror) =3D err_arg.args file_list.close() if not Opt.silent: sys.stderr.write("OS ERROR : %s : %s\n" % (str(errno), strerro= r)) @@ -210,13 +212,15 @@ def RevertCmd(Filename, Opt): sys.stderr.write("Subprocess ERROR : %s\n" % err_val) sys.stderr.flush() =20 - except IOError as (errno, strerror): + except IOError as err_arg: + (errno, strerror) =3D err_arg.args if not Opt.silent: sys.stderr.write("I/O ERROR : %d : %s\n" % (str(errno), strerr= or)) sys.stderr.write("ERROR : this command failed : %s\n" % CmdLin= e) sys.stderr.flush() =20 - except OSError as (errno, strerror): + except OSError as err_arg: + (errno, strerror) =3D err_arg.args if not Opt.silent: sys.stderr.write("OS ERROR : %d : %s\n" % (str(errno), strerro= r)) sys.stderr.write("ERROR : this command failed : %s\n" % CmdLin= e) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/= Python/AutoGen/AutoGen.py index 0f7454f55a7a..faec5506a0e6 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -431,7 +431,7 @@ class WorkspaceAutoGen(AutoGen): if pcdvalue.startswith('H'): try: pcdvalue =3D ValueExpressionEx= (pcdvalue[1:], PcdDatumType, self._GuidDict)(True) - except BadExpression, Value: + except BadExpression as Value: if Value.result > 1: EdkLogger.error('Parser', = FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' % (TokenSpac= eGuidCName, TokenCName, pcdvalue, Value)) @@ -448,7 +448,7 @@ class WorkspaceAutoGen(AutoGen): if pcdvalue.startswith('H'): try: pcdvalue =3D ValueExpr= essionEx(pcdvalue[1:], PcdDatumType, self._GuidDict)(True) - except BadExpression, Valu= e: + except BadExpression as Va= lue: EdkLogger.error('Parse= r', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' % (Token= SpaceGuidCName, TokenCName, pcdvalue, Value)) pcdvalue =3D 'H' + pcdvalue @@ -2469,9 +2469,9 @@ class PlatformAutoGen(AutoGen): if PcdValue: try: ToPcd.DefaultValue =3D ValueExpression(PcdValue)(True) - except WrnExpression, Value: + except WrnExpression as Value: ToPcd.DefaultValue =3D Value.result - except BadExpression, Value: + except BadExpression as Value: EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s]= Value "%s", %s' %(ToPcd.TokenSpaceGuidCName, ToPcd.TokenCName, ToPcd.Defau= ltValue, Value), File=3Dself.MetaFile) if ToPcd.DefaultValue: @@ -2481,7 +2481,7 @@ class PlatformAutoGen(AutoGen): _GuidDict.update(Guids) try: ToPcd.DefaultValue =3D ValueExpressionEx(ToPcd.Default= Value, ToPcd.DatumType, _GuidDict)(True) - except BadExpression, Value: + except BadExpression as Value: EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s]= Value "%s", %s' %(ToPcd.TokenSpaceGuidCName, ToPcd.TokenCName, ToPcd.Defau= ltValue, Value), File=3Dself.MetaFile) =20 diff --git a/BaseTools/Source/Python/AutoGen/GenDepex.py b/BaseTools/Source= /Python/AutoGen/GenDepex.py index 7aa22bd944a0..98a43db7a4e5 100644 --- a/BaseTools/Source/Python/AutoGen/GenDepex.py +++ b/BaseTools/Source/Python/AutoGen/GenDepex.py @@ -448,7 +448,7 @@ def Main(): os.utime(Option.OutputFile, None) else: Dpx.Generate() - except BaseException, X: + except BaseException as X: EdkLogger.quiet("") if Option !=3D None and Option.debug !=3D None: EdkLogger.quiet(traceback.format_exc()) diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/= Python/AutoGen/GenMake.py index 7d3374a49373..3f98a34d81ec 100644 --- a/BaseTools/Source/Python/AutoGen/GenMake.py +++ b/BaseTools/Source/Python/AutoGen/GenMake.py @@ -1027,7 +1027,7 @@ cleanlib: else: try: Fd =3D open(F.Path, 'r') - except BaseException, X: + except BaseException as X: EdkLogger.error("build", FILE_OPEN_FAILURE, ExtraData= =3DF.Path + "\n\t" + str(X)) =20 FileContent =3D Fd.read() diff --git a/BaseTools/Source/Python/AutoGen/UniClassObject.py b/BaseTools/= Source/Python/AutoGen/UniClassObject.py index 856d19cda270..2711fc104f52 100644 --- a/BaseTools/Source/Python/AutoGen/UniClassObject.py +++ b/BaseTools/Source/Python/AutoGen/UniClassObject.py @@ -242,7 +242,7 @@ class UniFileClassObject(object): if len(Lang) !=3D 3: try: FileIn =3D self.OpenUniFile(LongFilePath(File.Path)) - except UnicodeError, X: + except UnicodeError as X: EdkLogger.error("build", FILE_READ_FAILURE, "File read fai= lure: %s" % str(X), ExtraData=3DFile); except: EdkLogger.error("build", FILE_OPEN_FAILURE, ExtraData=3DFi= le); @@ -393,7 +393,7 @@ class UniFileClassObject(object): =20 try: FileIn =3D self.OpenUniFile(LongFilePath(File.Path)) - except UnicodeError, X: + except UnicodeError as X: EdkLogger.error("build", FILE_READ_FAILURE, "File read failure= : %s" % str(X), ExtraData=3DFile.Path); except: EdkLogger.error("build", FILE_OPEN_FAILURE, ExtraData=3DFile.P= ath); diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Sourc= e/Python/Common/Expression.py index 55fa06d414ea..216694325f96 100644 --- a/BaseTools/Source/Python/Common/Expression.py +++ b/BaseTools/Source/Python/Common/Expression.py @@ -231,7 +231,7 @@ class ValueExpression(object): } try: Val =3D eval(EvalStr, {}, Dict) - except Exception, Excpt: + except Exception as Excpt: raise BadExpression(str(Excpt)) =20 if Operator in ['and', 'or']: @@ -351,7 +351,7 @@ class ValueExpression(object): continue try: Val =3D self.Eval(Op, Val, EvalFunc()) - except WrnExpression, Warn: + except WrnExpression as Warn: self._WarnExcept =3D Warn Val =3D Warn.result return Val @@ -390,7 +390,7 @@ class ValueExpression(object): Op +=3D ' ' + self._Token try: Val =3D self.Eval(Op, Val, self._RelExpr()) - except WrnExpression, Warn: + except WrnExpression as Warn: self._WarnExcept =3D Warn Val =3D Warn.result return Val @@ -416,14 +416,14 @@ class ValueExpression(object): Val =3D self._UnaryExpr() try: return self.Eval('not', Val) - except WrnExpression, Warn: + except WrnExpression as Warn: self._WarnExcept =3D Warn return Warn.result if self._IsOperator(["~"]): Val =3D self._UnaryExpr() try: return self.Eval('~', Val) - except WrnExpression, Warn: + except WrnExpression as Warn: self._WarnExcept =3D Warn return Warn.result return self._IdenExpr() @@ -734,7 +734,7 @@ class ValueExpressionEx(ValueExpression): PcdValue =3D self.PcdValue try: PcdValue =3D ValueExpression.__call__(self, RealValue, Depth) - except WrnExpression, Value: + except WrnExpression as Value: PcdValue =3D Value.result =20 if PcdValue =3D=3D 'True': @@ -885,8 +885,8 @@ if __name__ =3D=3D '__main__': try: print ValueExpression(input)(True) print ValueExpression(input)(False) - except WrnExpression, Ex: + except WrnExpression as Ex: print Ex.result print str(Ex) - except Exception, Ex: + except Exception as Ex: print str(Ex) diff --git a/BaseTools/Source/Python/Common/FdfParserLite.py b/BaseTools/So= urce/Python/Common/FdfParserLite.py index 7d129bfcab59..ac03c3fef5bb 100644 --- a/BaseTools/Source/Python/Common/FdfParserLite.py +++ b/BaseTools/Source/Python/Common/FdfParserLite.py @@ -1190,7 +1190,7 @@ class FdfParser(object): # pass =20 =20 - except Warning, X: + except Warning as X: self.__UndoToken() FileLineTuple =3D GetRealFileLine(self.FileName, self.CurrentL= ineNumber) X.message +=3D '\nGot Token: \"%s\" from File %s\n' % (self.__= Token, FileLineTuple[0]) + \ @@ -3659,7 +3659,7 @@ if __name__ =3D=3D "__main__": import sys try: test_file =3D sys.argv[1] - except IndexError, v: + except IndexError as v: print "Usage: %s filename" % sys.argv[0] sys.exit(1) =20 @@ -3667,7 +3667,7 @@ if __name__ =3D=3D "__main__": try: parser.ParseFile() parser.CycleReferenceCheck() - except Warning, X: + except Warning as X: print X.message else: print "Success!" diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Pyth= on/Common/Misc.py index a8ed718aa5d8..f1eb4c5a7892 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -522,7 +522,7 @@ def SaveFileOnChange(File, Content, IsBinaryFile=3DTrue= ): Fd =3D open(File, "wb") Fd.write(Content) Fd.close() - except IOError, X: + except IOError as X: EdkLogger.error(None, FILE_CREATE_FAILURE, ExtraData=3D'IOError %s= ' % X) =20 return True @@ -556,7 +556,7 @@ def DataRestore(File): try: Fd =3D open(File, 'rb') Data =3D cPickle.load(Fd) - except Exception, e: + except Exception as e: EdkLogger.verbose("Failed to load [%s]\n\t%s" % (File, str(e))) Data =3D None finally: @@ -1494,7 +1494,7 @@ def ParseDevPathValue (Value): try: p =3D subprocess.Popen(Cmd, stdout=3Dsubprocess.PIPE, stderr=3Dsub= process.PIPE, shell=3DTrue) out, err =3D p.communicate() - except Exception, X: + except Exception as X: raise BadExpression("DevicePath: %s" % (str(X)) ) finally: subprocess._cleanup() @@ -1549,7 +1549,7 @@ def ParseFieldValue (Value): Value =3D Value[1:-1] try: Value =3D "'" + uuid.UUID(Value).get_bytes_le() + "'" - except ValueError, Message: + except ValueError as Message: raise BadExpression('%s' % Message) Value, Size =3D ParseFieldValue(Value) return Value, 16 diff --git a/BaseTools/Source/Python/Common/RangeExpression.py b/BaseTools/= Source/Python/Common/RangeExpression.py index b6c929fd885b..10b6ac55242b 100644 --- a/BaseTools/Source/Python/Common/RangeExpression.py +++ b/BaseTools/Source/Python/Common/RangeExpression.py @@ -441,7 +441,7 @@ class RangeExpression(object): Op =3D self._Token try: Val =3D self.Eval(Op, Val, EvalFunc()) - except WrnExpression, Warn: + except WrnExpression as Warn: self._WarnExcept =3D Warn Val =3D Warn.result return Val @@ -464,7 +464,7 @@ class RangeExpression(object): Op +=3D ' ' + self._Token try: Val =3D self.Eval(Op, Val, self._RelExpr()) - except WrnExpression, Warn: + except WrnExpression as Warn: self._WarnExcept =3D Warn Val =3D Warn.result return Val @@ -476,7 +476,7 @@ class RangeExpression(object): Val =3D self._NeExpr() try: return self.Eval(Token, Val) - except WrnExpression, Warn: + except WrnExpression as Warn: self._WarnExcept =3D Warn return Warn.result return self._IdenExpr() diff --git a/BaseTools/Source/Python/Common/VpdInfoFile.py b/BaseTools/Sour= ce/Python/Common/VpdInfoFile.py index 716155e96d29..14ccabe833db 100644 --- a/BaseTools/Source/Python/Common/VpdInfoFile.py +++ b/BaseTools/Source/Python/Common/VpdInfoFile.py @@ -246,7 +246,7 @@ def CallExtenalBPDGTool(ToolPath, VpdFileName): stdout=3Dsubprocess.PIPE,=20 stderr=3D subprocess.PIPE, shell=3DTrue) - except Exception, X: + except Exception as X: EdkLogger.error("BPDG", BuildToolError.COMMAND_FAILURE, ExtraData= =3D"%s" % (str(X))) (out, error) =3D PopenObject.communicate() print out diff --git a/BaseTools/Source/Python/Ecc/CParser.py b/BaseTools/Source/Pyth= on/Ecc/CParser.py index baa521f43cc4..39883aca07c4 100644 --- a/BaseTools/Source/Python/Ecc/CParser.py +++ b/BaseTools/Source/Python/Ecc/CParser.py @@ -180,7 +180,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -539,7 +539,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -816,7 +816,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -971,7 +971,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -1099,7 +1099,7 @@ class CParser(Parser): retval.stop =3D self.input.LT(-1) =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -1169,7 +1169,7 @@ class CParser(Parser): retval.stop =3D self.input.LT(-1) =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -1223,7 +1223,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -1270,7 +1270,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -1439,7 +1439,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -1472,7 +1472,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -1596,7 +1596,7 @@ class CParser(Parser): retval.stop =3D self.input.LT(-1) =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -1643,7 +1643,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -1706,7 +1706,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -1749,7 +1749,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -1868,7 +1868,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -1928,7 +1928,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -2010,7 +2010,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -2165,7 +2165,7 @@ class CParser(Parser): retval.stop =3D self.input.LT(-1) =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -2230,7 +2230,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -2282,7 +2282,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -2329,7 +2329,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -2471,7 +2471,7 @@ class CParser(Parser): retval.stop =3D self.input.LT(-1) =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -3063,7 +3063,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -3213,7 +3213,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -3469,7 +3469,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -3535,7 +3535,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -3624,7 +3624,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -3832,7 +3832,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -3888,7 +3888,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -3978,7 +3978,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -4226,7 +4226,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -4577,7 +4577,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -4697,7 +4697,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -4777,7 +4777,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -4842,7 +4842,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -4940,7 +4940,7 @@ class CParser(Parser): retval.stop =3D self.input.LT(-1) =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -5019,7 +5019,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -5110,7 +5110,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -5210,7 +5210,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -5362,7 +5362,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -5590,7 +5590,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -5651,7 +5651,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -5698,7 +5698,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -5796,7 +5796,7 @@ class CParser(Parser): retval.stop =3D self.input.LT(-1) =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -6002,7 +6002,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -6072,7 +6072,7 @@ class CParser(Parser): retval.stop =3D self.input.LT(-1) =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -6107,7 +6107,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -8142,7 +8142,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -8177,7 +8177,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -8224,7 +8224,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -8292,7 +8292,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -8362,7 +8362,7 @@ class CParser(Parser): retval.stop =3D self.input.LT(-1) =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -8422,7 +8422,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -8482,7 +8482,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -8542,7 +8542,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -8602,7 +8602,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -8676,7 +8676,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -8750,7 +8750,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -8824,7 +8824,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -9065,7 +9065,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -9162,7 +9162,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -9235,7 +9235,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -9308,7 +9308,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -12474,7 +12474,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -12567,7 +12567,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -14537,7 +14537,7 @@ class CParser(Parser): retval.stop =3D self.input.LT(-1) =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -16258,7 +16258,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -16329,7 +16329,7 @@ class CParser(Parser): retval.stop =3D self.input.LT(-1) =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -16442,7 +16442,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -16593,7 +16593,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -16710,7 +16710,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: diff --git a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaDataTable.py= b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaDataTable.py index a27e98c9752f..a4057ceb1775 100644 --- a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaDataTable.py +++ b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaDataTable.py @@ -98,7 +98,7 @@ class Table(object): SqlCommand =3D """drop table IF EXISTS %s""" % self.Table try: self.Cur.execute(SqlCommand) - except Exception, e: + except Exception as e: print "An error occurred when Drop a table:", e.args[0] =20 ## Get count diff --git a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.p= y b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py index ba478f9ecf10..2fef87c4180a 100644 --- a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py @@ -1183,7 +1183,7 @@ class DscParser(MetaFileParser): =20 try: Processer[self._ItemType]() - except EvaluationException, Excpt: + except EvaluationException as Excpt: #=20 # Only catch expression evaluation error here. We need to = report # the precise number of line on which the error occurred @@ -1192,7 +1192,7 @@ class DscParser(MetaFileParser): # EdkLogger.error('Parser', FORMAT_INVALID, "Invalid expre= ssion: %s" % str(Excpt), # File=3Dself._FileWithError, ExtraData=3D= ' '.join(self._ValueList), # Line=3Dself._LineIndex+1) - except MacroException, Excpt: + except MacroException as Excpt: EdkLogger.error('Parser', FORMAT_INVALID, str(Excpt), File=3Dself._FileWithError, ExtraData=3D' = '.join(self._ValueList),=20 Line=3Dself._LineIndex+1) @@ -1305,10 +1305,10 @@ class DscParser(MetaFileParser): Macros.update(GlobalData.gGlobalDefines) try: Result =3D ValueExpression(self._ValueList[1], Macros)() - except SymbolNotFound, Exc: + except SymbolNotFound as Exc: EdkLogger.debug(EdkLogger.DEBUG_5, str(Exc), self._ValueLi= st[1]) Result =3D False - except WrnExpression, Excpt: + except WrnExpression as Excpt: #=20 # Catch expression evaluation warning here. We need to rep= ort # the precise number of line and return the evaluation res= ult @@ -1317,7 +1317,7 @@ class DscParser(MetaFileParser): File=3Dself._FileWithError, ExtraData=3D' = '.join(self._ValueList),=20 Line=3Dself._LineIndex+1) Result =3D Excpt.result - except BadExpression, Exc: + except BadExpression as Exc: EdkLogger.debug(EdkLogger.DEBUG_5, str(Exc), self._ValueLi= st[1]) Result =3D False =20 @@ -1437,13 +1437,13 @@ class DscParser(MetaFileParser): PcdValue =3D ValueList[0] =20 try: ValueList[0] =3D ValueExpression(PcdValue, self._Macros)(T= rue) - except WrnExpression, Value: + except WrnExpression as Value: ValueList[0] =3D Value.result =20 else: PcdValue =3D ValueList[-1] try: ValueList[-1] =3D ValueExpression(PcdValue, self._Macros)(= True) - except WrnExpression, Value: + except WrnExpression as Value: ValueList[-1] =3D Value.result =20 if ValueList[-1] =3D=3D 'True': diff --git a/BaseTools/Source/Python/Ecc/Xml/XmlRoutines.py b/BaseTools/Sou= rce/Python/Ecc/Xml/XmlRoutines.py index b93588eea61a..4ce8edf5573a 100644 --- a/BaseTools/Source/Python/Ecc/Xml/XmlRoutines.py +++ b/BaseTools/Source/Python/Ecc/Xml/XmlRoutines.py @@ -214,7 +214,7 @@ def XmlParseFile(FileName): Dom =3D xml.dom.minidom.parse(XmlFile) XmlFile.close() return Dom - except Exception, X: + except Exception as X: print X return "" =20 diff --git a/BaseTools/Source/Python/Ecc/c.py b/BaseTools/Source/Python/Ecc= /c.py index 35b7405e550d..8a4b10727a07 100644 --- a/BaseTools/Source/Python/Ecc/c.py +++ b/BaseTools/Source/Python/Ecc/c.py @@ -2627,7 +2627,7 @@ if __name__ =3D=3D '__main__': # CollectSourceCodeDataIntoDB(sys.argv[1]) try: test_file =3D sys.argv[1] - except IndexError, v: + except IndexError as v: print "Usage: %s filename" % sys.argv[0] sys.exit(1) MsgList =3D CheckFuncHeaderDoxygenComments(test_file) diff --git a/BaseTools/Source/Python/Eot/CParser.py b/BaseTools/Source/Pyth= on/Eot/CParser.py index baa521f43cc4..39883aca07c4 100644 --- a/BaseTools/Source/Python/Eot/CParser.py +++ b/BaseTools/Source/Python/Eot/CParser.py @@ -180,7 +180,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -539,7 +539,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -816,7 +816,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -971,7 +971,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -1099,7 +1099,7 @@ class CParser(Parser): retval.stop =3D self.input.LT(-1) =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -1169,7 +1169,7 @@ class CParser(Parser): retval.stop =3D self.input.LT(-1) =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -1223,7 +1223,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -1270,7 +1270,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -1439,7 +1439,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -1472,7 +1472,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -1596,7 +1596,7 @@ class CParser(Parser): retval.stop =3D self.input.LT(-1) =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -1643,7 +1643,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -1706,7 +1706,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -1749,7 +1749,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -1868,7 +1868,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -1928,7 +1928,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -2010,7 +2010,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -2165,7 +2165,7 @@ class CParser(Parser): retval.stop =3D self.input.LT(-1) =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -2230,7 +2230,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -2282,7 +2282,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -2329,7 +2329,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -2471,7 +2471,7 @@ class CParser(Parser): retval.stop =3D self.input.LT(-1) =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -3063,7 +3063,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -3213,7 +3213,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -3469,7 +3469,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -3535,7 +3535,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -3624,7 +3624,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -3832,7 +3832,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -3888,7 +3888,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -3978,7 +3978,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -4226,7 +4226,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -4577,7 +4577,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -4697,7 +4697,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -4777,7 +4777,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -4842,7 +4842,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -4940,7 +4940,7 @@ class CParser(Parser): retval.stop =3D self.input.LT(-1) =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -5019,7 +5019,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -5110,7 +5110,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -5210,7 +5210,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -5362,7 +5362,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -5590,7 +5590,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -5651,7 +5651,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -5698,7 +5698,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -5796,7 +5796,7 @@ class CParser(Parser): retval.stop =3D self.input.LT(-1) =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -6002,7 +6002,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -6072,7 +6072,7 @@ class CParser(Parser): retval.stop =3D self.input.LT(-1) =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -6107,7 +6107,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -8142,7 +8142,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -8177,7 +8177,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -8224,7 +8224,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -8292,7 +8292,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -8362,7 +8362,7 @@ class CParser(Parser): retval.stop =3D self.input.LT(-1) =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -8422,7 +8422,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -8482,7 +8482,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -8542,7 +8542,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -8602,7 +8602,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -8676,7 +8676,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -8750,7 +8750,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -8824,7 +8824,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -9065,7 +9065,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -9162,7 +9162,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -9235,7 +9235,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -9308,7 +9308,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -12474,7 +12474,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -12567,7 +12567,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -14537,7 +14537,7 @@ class CParser(Parser): retval.stop =3D self.input.LT(-1) =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -16258,7 +16258,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -16329,7 +16329,7 @@ class CParser(Parser): retval.stop =3D self.input.LT(-1) =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -16442,7 +16442,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -16593,7 +16593,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: @@ -16710,7 +16710,7 @@ class CParser(Parser): =20 =20 =20 - except RecognitionException, re: + except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: diff --git a/BaseTools/Source/Python/Eot/FvImage.py b/BaseTools/Source/Pyth= on/Eot/FvImage.py index 0f742c7d86c2..6696623aba68 100644 --- a/BaseTools/Source/Python/Eot/FvImage.py +++ b/BaseTools/Source/Python/Eot/FvImage.py @@ -1411,7 +1411,7 @@ def Main(): try: Option =3D GetOptions() build.main() - except Exception, e: + except Exception as e: print e return 1 =20 diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source= /Python/GenFds/FdfParser.py index 0190be884a33..15b2b792b2e1 100644 --- a/BaseTools/Source/Python/GenFds/FdfParser.py +++ b/BaseTools/Source/Python/GenFds/FdfParser.py @@ -938,7 +938,7 @@ class FdfParser: return ValueExpression(Expression, MacroPcdDict)(True) else: return ValueExpression(Expression, MacroPcdDict)() - except WrnExpression, Excpt: + except WrnExpression as Excpt: #=20 # Catch expression evaluation warning here. We need to rep= ort # the precise number of line and return the evaluation res= ult @@ -947,7 +947,7 @@ class FdfParser: File=3Dself.FileName, ExtraData=3Dself.__C= urrentLine(),=20 Line=3DLine) return Excpt.result - except Exception, Excpt: + except Exception as Excpt: if hasattr(Excpt, 'Pcd'): if Excpt.Pcd in GlobalData.gPlatformOtherPcds: Info =3D GlobalData.gPlatformOtherPcds[Excpt.Pcd] @@ -1414,7 +1414,7 @@ class FdfParser: while self.__GetFd() or self.__GetFv() or self.__GetFmp() or s= elf.__GetCapsule() or self.__GetVtf() or self.__GetRule() or self.__GetOpti= onRom(): pass =20 - except Warning, X: + except Warning as X: self.__UndoToken() #'\n\tGot Token: \"%s\" from File %s\n' % (self.__Token, FileL= ineTuple[0]) + \ # At this point, the closest parent would be the included file= itself @@ -4817,7 +4817,7 @@ if __name__ =3D=3D "__main__": import sys try: test_file =3D sys.argv[1] - except IndexError, v: + except IndexError as v: print "Usage: %s filename" % sys.argv[0] sys.exit(1) =20 @@ -4825,7 +4825,7 @@ if __name__ =3D=3D "__main__": try: parser.ParseFile() parser.CycleReferenceCheck() - except Warning, X: + except Warning as X: print str(X) else: print "Success!" diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Py= thon/GenFds/GenFds.py index 4a5d6f476abd..51b79397337c 100644 --- a/BaseTools/Source/Python/GenFds/GenFds.py +++ b/BaseTools/Source/Python/GenFds/GenFds.py @@ -337,10 +337,10 @@ def main(): """Display FV space info.""" GenFds.DisplayFvSpaceInfo(FdfParserObj) =20 - except FdfParser.Warning, X: + except FdfParser.Warning as X: EdkLogger.error(X.ToolName, FORMAT_INVALID, File=3DX.FileName, Lin= e=3DX.LineNumber, ExtraData=3DX.Message, RaiseError=3DFalse) ReturnCode =3D FORMAT_INVALID - except FatalError, X: + except FatalError as X: if Options.debug !=3D None: import traceback EdkLogger.quiet(traceback.format_exc()) diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseT= ools/Source/Python/GenFds/GenFdsGlobalVariable.py index 371d5a8217f7..da955fe1a4f7 100644 --- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py +++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py @@ -722,7 +722,7 @@ class GenFdsGlobalVariable: =20 try: PopenObject =3D subprocess.Popen(' '.join(cmd), stdout=3Dsubpr= ocess.PIPE, stderr=3Dsubprocess.PIPE, shell=3DTrue) - except Exception, X: + except Exception as X: EdkLogger.error("GenFds", COMMAND_FAILURE, ExtraData=3D"%s: %s= " % (str(X), cmd[0])) (out, error) =3D PopenObject.communicate() =20 diff --git a/BaseTools/Source/Python/TargetTool/TargetTool.py b/BaseTools/S= ource/Python/TargetTool/TargetTool.py index bfdf763a7abc..882b016bf058 100644 --- a/BaseTools/Source/Python/TargetTool/TargetTool.py +++ b/BaseTools/Source/Python/TargetTool/TargetTool.py @@ -254,7 +254,7 @@ if __name__ =3D=3D '__main__': FileHandle.RWFile('#', '=3D', 0) else: FileHandle.RWFile('#', '=3D', 1) - except Exception, e: + except Exception as e: last_type, last_value, last_tb =3D sys.exc_info() traceback.print_exception(last_type, last_value, last_tb) =20 diff --git a/BaseTools/Source/Python/Trim/Trim.py b/BaseTools/Source/Python= /Trim/Trim.py index d1e40b025caa..05ba86262133 100644 --- a/BaseTools/Source/Python/Trim/Trim.py +++ b/BaseTools/Source/Python/Trim/Trim.py @@ -667,7 +667,7 @@ def Main(): EdkLogger.SetLevel(CommandOptions.LogLevel + 1) else: EdkLogger.SetLevel(CommandOptions.LogLevel) - except FatalError, X: + except FatalError as X: return 1 =20 try: @@ -687,7 +687,7 @@ def Main(): if CommandOptions.OutputFile =3D=3D None: CommandOptions.OutputFile =3D os.path.splitext(InputFile)[= 0] + '.iii' TrimPreprocessedFile(InputFile, CommandOptions.OutputFile, Com= mandOptions.ConvertHex, CommandOptions.TrimLong) - except FatalError, X: + except FatalError as X: import platform import traceback if CommandOptions !=3D None and CommandOptions.LogLevel <=3D EdkLo= gger.DEBUG_9: diff --git a/BaseTools/Source/Python/UPT/Core/DependencyRules.py b/BaseTool= s/Source/Python/UPT/Core/DependencyRules.py index 26c5a97da80f..3a7c9809e31a 100644 --- a/BaseTools/Source/Python/UPT/Core/DependencyRules.py +++ b/BaseTools/Source/Python/UPT/Core/DependencyRules.py @@ -394,7 +394,7 @@ def VerifyRemoveModuleDep(Path, DpPackagePathList): return False else: return True - except FatalError, ErrCode: + except FatalError as ErrCode: if ErrCode.message =3D=3D EDK1_INF_ERROR: Logger.Warn("UPT", ST.WRN_EDK1_INF_FOUND%Path) @@ -446,7 +446,7 @@ def VerifyReplaceModuleDep(Path, DpPackagePathList, Oth= erPkgList): return False else: return True - except FatalError, ErrCode: + except FatalError as ErrCode: if ErrCode.message =3D=3D EDK1_INF_ERROR: Logger.Warn("UPT", ST.WRN_EDK1_INF_FOUND%Path) diff --git a/BaseTools/Source/Python/UPT/Core/DistributionPackageClass.py b= /BaseTools/Source/Python/UPT/Core/DistributionPackageClass.py index 9c55e0ea88a7..81c67fb510a2 100644 --- a/BaseTools/Source/Python/UPT/Core/DistributionPackageClass.py +++ b/BaseTools/Source/Python/UPT/Core/DistributionPackageClass.py @@ -155,7 +155,7 @@ class DistributionPackageClass(object): ModuleObj.GetName(), \ ModuleObj.GetCombinePath())] =3D Modul= eObj PackageObj.SetModuleDict(ModuleDict) - except FatalError, ErrCode: + except FatalError as ErrCode: if ErrCode.message =3D=3D EDK1_INF_ERROR: Logger.Warn("UPT", ST.WRN_EDK1_INF_FOUND%Filename) @@ -181,7 +181,7 @@ class DistributionPackageClass(object): ModuleObj.GetName(),=20 ModuleObj.GetCombinePath()) self.ModuleSurfaceArea[ModuleKey] =3D ModuleObj - except FatalError, ErrCode: + except FatalError as ErrCode: if ErrCode.message =3D=3D EDK1_INF_ERROR: Logger.Error("UPT", EDK1_INF_ERROR, diff --git a/BaseTools/Source/Python/UPT/Core/IpiDb.py b/BaseTools/Source/P= ython/UPT/Core/IpiDb.py index f147963288ad..baf687ef99ba 100644 --- a/BaseTools/Source/Python/UPT/Core/IpiDb.py +++ b/BaseTools/Source/Python/UPT/Core/IpiDb.py @@ -230,7 +230,7 @@ class IpiDatabase(object): self._AddDp(DpObj.Header.GetGuid(), DpObj.Header.GetVersion(),= \ NewDpPkgFileName, DpPkgFileName, RePackage) =20 - except sqlite3.IntegrityError, DetailMsg: + except sqlite3.IntegrityError as DetailMsg: Logger.Error("UPT", UPT_DB_UPDATE_ERROR, ST.ERR_UPT_DB_UPDATE_ERROR, diff --git a/BaseTools/Source/Python/UPT/Core/PackageFile.py b/BaseTools/So= urce/Python/UPT/Core/PackageFile.py index 5fafd85bffbf..db4725b1a56d 100644 --- a/BaseTools/Source/Python/UPT/Core/PackageFile.py +++ b/BaseTools/Source/Python/UPT/Core/PackageFile.py @@ -51,7 +51,7 @@ class PackageFile: self._Files =3D {} for Filename in self._ZipFile.namelist(): self._Files[os.path.normpath(Filename)] =3D Filename - except BaseException, Xstr: + except BaseException as Xstr: Logger.Error("PackagingTool", FILE_OPEN_FAILURE,=20 ExtraData=3D"%s (%s)" % (FileName, str(Xstr))) =20 @@ -106,7 +106,7 @@ class PackageFile: ExtraData=3D"[%s] in %s" % (Which, self._FileN= ame)) try: FileContent =3D self._ZipFile.read(self._Files[Which]) - except BaseException, Xstr: + except BaseException as Xstr: Logger.Error("PackagingTool", FILE_DECOMPRESS_FAILURE,=20 ExtraData=3D"[%s] in %s (%s)" % (Which, \ self._FileName,= \ @@ -119,14 +119,14 @@ class PackageFile: return else: ToFile =3D __FileHookOpen__(ToDest, 'wb') - except BaseException, Xstr: + except BaseException as Xstr: Logger.Error("PackagingTool", FILE_OPEN_FAILURE,=20 ExtraData=3D"%s (%s)" % (ToDest, str(Xstr))) =20 try: ToFile.write(FileContent) ToFile.close() - except BaseException, Xstr: + except BaseException as Xstr: Logger.Error("PackagingTool", FILE_WRITE_FAILURE,=20 ExtraData=3D"%s (%s)" % (ToDest, str(Xstr))) =20 @@ -228,7 +228,7 @@ class PackageFile: return Logger.Info("packing ..." + File) self._ZipFile.write(File, ArcName) - except BaseException, Xstr: + except BaseException as Xstr: Logger.Error("PackagingTool", FILE_COMPRESS_FAILURE, ExtraData=3D"%s (%s)" % (File, str(Xstr))) =20 @@ -242,7 +242,7 @@ class PackageFile: if os.path.splitext(ArcName)[1].lower() =3D=3D '.pkg': Data =3D Data.encode('utf_8') self._ZipFile.writestr(ArcName, Data) - except BaseException, Xstr: + except BaseException as Xstr: Logger.Error("PackagingTool", FILE_COMPRESS_FAILURE, ExtraData=3D"%s (%s)" % (ArcName, str(Xstr))) =20 diff --git a/BaseTools/Source/Python/UPT/InstallPkg.py b/BaseTools/Source/P= ython/UPT/InstallPkg.py index a8d0e1ec440a..e268f7892290 100644 --- a/BaseTools/Source/Python/UPT/InstallPkg.py +++ b/BaseTools/Source/Python/UPT/InstallPkg.py @@ -537,7 +537,7 @@ def Main(Options =3D None): Options, Dep, WorkspaceDir, DataBase) ReturnCode =3D 0 =20 - except FatalError, XExcept: + except FatalError as XExcept: ReturnCode =3D XExcept.args[0] if Logger.GetLevel() <=3D Logger.DEBUG_9: Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) += format_exc()) diff --git a/BaseTools/Source/Python/UPT/InventoryWs.py b/BaseTools/Source/= Python/UPT/InventoryWs.py index 824e1c288947..cd92753a8d4b 100644 --- a/BaseTools/Source/Python/UPT/InventoryWs.py +++ b/BaseTools/Source/Python/UPT/InventoryWs.py @@ -92,7 +92,7 @@ def Main(Options =3D None): DataBase =3D GlobalData.gDB InventoryDistInstalled(DataBase) =20 ReturnCode =3D 0 =20 - except FatalError, XExcept: + except FatalError as XExcept: ReturnCode =3D XExcept.args[0] if Logger.GetLevel() <=3D Logger.DEBUG_9: Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) += format_exc()) diff --git a/BaseTools/Source/Python/UPT/Library/CommentParsing.py b/BaseTo= ols/Source/Python/UPT/Library/CommentParsing.py index e6d45103f94b..9cd7b60e16ab 100644 --- a/BaseTools/Source/Python/UPT/Library/CommentParsing.py +++ b/BaseTools/Source/Python/UPT/Library/CommentParsing.py @@ -217,7 +217,7 @@ def ParsePcdErrorCode (Value =3D None, ContainerFile = =3D None, LineNum =3D None): # To delete the tailing 'L' # return hex(ErrorCode)[:-1] - except ValueError, XStr: + except ValueError as XStr: if XStr: pass Logger.Error('Parser',=20 diff --git a/BaseTools/Source/Python/UPT/Library/ExpressionValidate.py b/Ba= seTools/Source/Python/UPT/Library/ExpressionValidate.py index 090c7eb95716..ca21e6995217 100644 --- a/BaseTools/Source/Python/UPT/Library/ExpressionValidate.py +++ b/BaseTools/Source/Python/UPT/Library/ExpressionValidate.py @@ -297,7 +297,7 @@ class _LogicalExpressionParser(_ExprBase): try: if self.LogicalExpression() not in [self.ARITH, self.LOGICAL, = self.REALLOGICAL, self.STRINGITEM]: return False, ST.ERR_EXPR_LOGICAL % self.Token - except _ExprError, XExcept: + except _ExprError as XExcept: return False, XExcept.Error self.SkipWhitespace() if self.Index !=3D self.Len: @@ -327,7 +327,7 @@ class _ValidRangeExpressionParser(_ExprBase): try: if self.RangeExpression() not in [self.HEX, self.INT]: return False, ST.ERR_EXPR_RANGE % self.Token - except _ExprError, XExcept: + except _ExprError as XExcept: return False, XExcept.Error =20 self.SkipWhitespace() @@ -423,7 +423,7 @@ class _ValidListExpressionParser(_ExprBase): try: if self.ListExpression() not in [self.NUM]: return False, ST.ERR_EXPR_LIST % self.Token - except _ExprError, XExcept: + except _ExprError as XExcept: return False, XExcept.Error =20 self.SkipWhitespace() @@ -457,7 +457,7 @@ class _StringTestParser(_ExprBase): return False, ST.ERR_EXPR_EMPTY try: self.StringTest() - except _ExprError, XExcept: + except _ExprError as XExcept: return False, XExcept.Error return True, '' =20 diff --git a/BaseTools/Source/Python/UPT/Library/UniClassObject.py b/BaseTo= ols/Source/Python/UPT/Library/UniClassObject.py index 1fbbf2e49887..b00bba1f8440 100644 --- a/BaseTools/Source/Python/UPT/Library/UniClassObject.py +++ b/BaseTools/Source/Python/UPT/Library/UniClassObject.py @@ -329,9 +329,9 @@ class UniFileClassObject(object): if len(Lang) !=3D 3: try: FileIn =3D codecs.open(File.Path, mode=3D'rb', encoding=3D= 'utf_8').readlines() - except UnicodeError, Xstr: + except UnicodeError as Xstr: FileIn =3D codecs.open(File.Path, mode=3D'rb', encoding=3D= 'utf_16').readlines() - except UnicodeError, Xstr: + except UnicodeError as Xstr: FileIn =3D codecs.open(File.Path, mode=3D'rb', encoding=3D= 'utf_16_le').readlines() except: EdkLogger.Error("Unicode File Parser",=20 @@ -438,7 +438,7 @@ class UniFileClassObject(object): =20 try: FileIn =3D codecs.open(File.Path, mode=3D'rb', encoding=3D'utf= _8').readlines() - except UnicodeError, Xstr: + except UnicodeError as Xstr: FileIn =3D codecs.open(File.Path, mode=3D'rb', encoding=3D'utf= _16').readlines() except UnicodeError: FileIn =3D codecs.open(File.Path, mode=3D'rb', encoding=3D'utf= _16_le').readlines() @@ -1060,7 +1060,7 @@ class UniFileClassObject(object): ExtraData=3DFilaPath) try: FileIn =3D codecs.open(FilaPath, mode=3D'rb', encoding=3D'utf_= 8').readlines() - except UnicodeError, Xstr: + except UnicodeError as Xstr: FileIn =3D codecs.open(FilaPath, mode=3D'rb', encoding=3D'utf_= 16').readlines() except UnicodeError: FileIn =3D codecs.open(FilaPath, mode=3D'rb', encoding=3D'utf_= 16_le').readlines() diff --git a/BaseTools/Source/Python/UPT/Library/Xml/XmlRoutines.py b/BaseT= ools/Source/Python/UPT/Library/Xml/XmlRoutines.py index d7614b884990..fd02efb6bf04 100644 --- a/BaseTools/Source/Python/UPT/Library/Xml/XmlRoutines.py +++ b/BaseTools/Source/Python/UPT/Library/Xml/XmlRoutines.py @@ -224,6 +224,6 @@ def XmlParseFile(FileName): Dom =3D xml.dom.minidom.parse(XmlFile) XmlFile.close() return Dom - except BaseException, XExcept: + except BaseException as XExcept: XmlFile.close() Logger.Error('\nUPT', PARSER_ERROR, XExcept, File=3DFileName, Rais= eError=3DTrue) diff --git a/BaseTools/Source/Python/UPT/MkPkg.py b/BaseTools/Source/Python= /UPT/MkPkg.py index 87c84f0cc25b..99d6bcc19220 100644 --- a/BaseTools/Source/Python/UPT/MkPkg.py +++ b/BaseTools/Source/Python/UPT/MkPkg.py @@ -213,7 +213,7 @@ def Main(Options =3D None): Logger.Quiet(ST.MSG_FINISH) ReturnCode =3D 0 =20 - except FatalError, XExcept: + except FatalError as XExcept: ReturnCode =3D XExcept.args[0] =20 if Logger.GetLevel() <=3D Logger.DEBUG_9: Logger.Quiet(ST.MSG_PYTHON_ON % \ diff --git a/BaseTools/Source/Python/UPT/ReplacePkg.py b/BaseTools/Source/P= ython/UPT/ReplacePkg.py index efbf68a4ecc6..6f52b4f8f8e8 100644 --- a/BaseTools/Source/Python/UPT/ReplacePkg.py +++ b/BaseTools/Source/Python/UPT/ReplacePkg.py @@ -71,7 +71,7 @@ def Main(Options =3D None): InstallDp(DistPkg, DpPkgFileName, ContentZipFile, Options, Dep, Wo= rkspaceDir, DataBase) ReturnCode =3D 0 =20 - except FatalError, XExcept: + except FatalError as XExcept: ReturnCode =3D XExcept.args[0] if Logger.GetLevel() <=3D Logger.DEBUG_9: Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), diff --git a/BaseTools/Source/Python/UPT/RmPkg.py b/BaseTools/Source/Python= /UPT/RmPkg.py index ea842c11859f..6427a8f16c88 100644 --- a/BaseTools/Source/Python/UPT/RmPkg.py +++ b/BaseTools/Source/Python/UPT/RmPkg.py @@ -157,7 +157,7 @@ def Main(Options =3D None): =20 ReturnCode =3D 0 =20 - except FatalError, XExcept: + except FatalError as XExcept: ReturnCode =3D XExcept.args[0] =20 if Logger.GetLevel() <=3D Logger.DEBUG_9: Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) += \ diff --git a/BaseTools/Source/Python/UPT/TestInstall.py b/BaseTools/Source/= Python/UPT/TestInstall.py index 899cae56aa87..d8918737f907 100644 --- a/BaseTools/Source/Python/UPT/TestInstall.py +++ b/BaseTools/Source/Python/UPT/TestInstall.py @@ -68,12 +68,12 @@ def Main(Options=3DNone): else: Logger.Quiet(ST.MSG_TEST_INSTALL_FAIL) =20 - except TE.FatalError, XExcept: + except TE.FatalError as XExcept: ReturnCode =3D XExcept.args[0] if Logger.GetLevel() <=3D Logger.DEBUG_9: Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) += format_exc()) =20 - except Exception, x: + except Exception as x: ReturnCode =3D TE.CODE_ERROR Logger.Error( "\nTestInstallPkg", diff --git a/BaseTools/Source/Python/UPT/UPT.py b/BaseTools/Source/Python/U= PT/UPT.py index 325b96bf560d..0bfcc44e3f19 100644 --- a/BaseTools/Source/Python/UPT/UPT.py +++ b/BaseTools/Source/Python/UPT/UPT.py @@ -179,7 +179,7 @@ def Main(): =20 try: GlobalData.gWORKSPACE, GlobalData.gPACKAGE_PATH =3D GetWorkspace() - except FatalError, XExcept: + except FatalError as XExcept: if Logger.GetLevel() <=3D Logger.DEBUG_9: Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) += format_exc()) return XExcept.args[0] @@ -294,7 +294,7 @@ def Main(): return OPTION_MISSING =20 ReturnCode =3D RunModule(Opt) - except FatalError, XExcept: + except FatalError as XExcept: ReturnCode =3D XExcept.args[0] if Logger.GetLevel() <=3D Logger.DEBUG_9: Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) += \ diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/= Source/Python/Workspace/DscBuildData.py index 4a87fd176294..5824266dc4fe 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -819,11 +819,11 @@ class DscBuildData(PlatformBuildClassObject): if ValueList[Index] and PcdType not in [MODEL_PCD_FEATURE_FLAG, MO= DEL_PCD_FIXED_AT_BUILD]: try: ValueList[Index] =3D ValueExpression(ValueList[Index], Glo= balData.gPlatformPcds)(True) - except WrnExpression, Value: + except WrnExpression as Value: ValueList[Index] =3D Value.result - except BadExpression, Value: + except BadExpression as Value: EdkLogger.error('Parser', FORMAT_INVALID, Value, File=3Dse= lf.MetaFile, Line=3Dself._LineIndex + 1) - except EvaluationException, Excpt: + except EvaluationException as Excpt: if hasattr(Excpt, 'Pcd'): if Excpt.Pcd in GlobalData.gPlatformOtherPcds: EdkLogger.error('Parser', FORMAT_INVALID, "Cannot = use this PCD (%s) in an expression as" @@ -840,7 +840,7 @@ class DscBuildData(PlatformBuildClassObject): DatumType =3D self._DecPcds[PcdCName, TokenSpaceGuid].DatumType try: ValueList[Index] =3D ValueExpressionEx(ValueList[Index], D= atumType, self._GuidDict)(True) - except BadExpression, Value: + except BadExpression as Value: EdkLogger.error('Parser', FORMAT_INVALID, Value, File=3Dse= lf.MetaFile, Line=3DLineNo, ExtraData=3D"PCD [%s.%s] Value \"%s\" " % = (TokenSpaceGuid, PcdCName, ValueList[Index])) Valid, ErrStr =3D CheckPcdDatum(self._DecPcds[PcdCName, TokenS= paceGuid].DatumType, ValueList[Index]) diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTools/= Source/Python/Workspace/InfBuildData.py index 7ea9b56d5dec..67c08ee47841 100644 --- a/BaseTools/Source/Python/Workspace/InfBuildData.py +++ b/BaseTools/Source/Python/Workspace/InfBuildData.py @@ -1148,7 +1148,7 @@ class InfBuildData(ModuleBuildClassObject): else: try: Pcd.DefaultValue =3D ValueExpressionEx(Pcd.Def= aultValue, Pcd.DatumType, self.Guids)(True) - except BadExpression, Value: + except BadExpression as Value: EdkLogger.error('Parser', FORMAT_INVALID, 'PCD= [%s.%s] Value "%s", %s' %(TokenSpaceGuid, PcdRealName, Pcd.DefaultValue, V= alue), File=3Dself.MetaFile, Line=3DL= ineNo) break diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTool= s/Source/Python/Workspace/MetaFileParser.py index b2b0e282eb91..74fa4d31b109 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -1327,7 +1327,7 @@ class DscParser(MetaFileParser): self._InSubsection =3D False try: Processer[self._ItemType]() - except EvaluationException, Excpt: + except EvaluationException as Excpt: #=20 # Only catch expression evaluation error here. We need to = report # the precise number of line on which the error occurred @@ -1349,7 +1349,7 @@ class DscParser(MetaFileParser): EdkLogger.error('Parser', FORMAT_INVALID, "Invalid exp= ression: %s" % str(Excpt), File=3Dself._FileWithError, ExtraData= =3D' '.join(self._ValueList), Line=3Dself._LineIndex + 1) - except MacroException, Excpt: + except MacroException as Excpt: EdkLogger.error('Parser', FORMAT_INVALID, str(Excpt), File=3Dself._FileWithError, ExtraData=3D' = '.join(self._ValueList), Line=3Dself._LineIndex + 1) @@ -1447,10 +1447,10 @@ class DscParser(MetaFileParser): Macros.update(GlobalData.gGlobalDefines) try: Result =3D ValueExpression(self._ValueList[1], Macros)() - except SymbolNotFound, Exc: + except SymbolNotFound as Exc: EdkLogger.debug(EdkLogger.DEBUG_5, str(Exc), self._ValueLi= st[1]) Result =3D False - except WrnExpression, Excpt: + except WrnExpression as Excpt: #=20 # Catch expression evaluation warning here. We need to rep= ort # the precise number of line and return the evaluation res= ult @@ -1591,7 +1591,7 @@ class DscParser(MetaFileParser): if PcdValue and "." not in self._ValueList[0]: try: ValList[Index] =3D ValueExpression(PcdValue, self._Macros)= (True) - except WrnExpression, Value: + except WrnExpression as Value: ValList[Index] =3D Value.result =20 if ValList[Index] =3D=3D 'True': @@ -1988,15 +1988,15 @@ class DecParser(MetaFileParser): if PcdValue: try: ValueList[0] =3D ValueExpression(PcdValue, self._AllPc= dDict)(True) - except WrnExpression, Value: + except WrnExpression as Value: ValueList[0] =3D Value.result - except BadExpression, Value: + except BadExpression as Value: EdkLogger.error('Parser', FORMAT_INVALID, Value, File= =3Dself.MetaFile, Line=3Dself._LineIndex + 1) =20 if ValueList[0]: try: ValueList[0] =3D ValueExpressionEx(ValueList[0], Value= List[1], self._GuidDict)(True) - except BadExpression, Value: + except BadExpression as Value: EdkLogger.error('Parser', FORMAT_INVALID, Value, Extra= Data=3Dself._CurrentLine, File=3Dself.MetaFile, Line=3Dself._LineIndex + 1) # check format of default value against the datum type IsValid, Cause =3D CheckPcdDatum(ValueList[1], ValueList[0]) diff --git a/BaseTools/Source/Python/Workspace/MetaFileTable.py b/BaseTools= /Source/Python/Workspace/MetaFileTable.py index d8549c9d66e6..92fcf6dd2b22 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileTable.py +++ b/BaseTools/Source/Python/Workspace/MetaFileTable.py @@ -63,7 +63,7 @@ class MetaFileTable(Table): # update the timestamp in database self._FileIndexTable.SetFileTimeStamp(self.IdBase, TimeSta= mp) return False - except Exception, Exc: + except Exception as Exc: EdkLogger.debug(EdkLogger.DEBUG_5, str(Exc)) return False return True @@ -250,7 +250,7 @@ class PackageTable(MetaFileTable): if comment.startswith("@Expression"): comment =3D comment.replace("@Expression", "", 1) expressions.append(comment.split("|")[1].strip()) - except Exception, Exc: + except Exception as Exc: ValidType =3D "" if oricomment.startswith("@ValidRange"): ValidType =3D "@ValidRange" diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Sourc= e/Python/build/BuildReport.py index d6e943d2f1d4..c3bfecf8cc66 100644 --- a/BaseTools/Source/Python/build/BuildReport.py +++ b/BaseTools/Source/Python/build/BuildReport.py @@ -649,7 +649,7 @@ class ModuleReport(object): cmd =3D ["GenFw", "--rebase", str(0), "-o", Tempfile, Defa= ultEFIfile] try: PopenObject =3D subprocess.Popen(' '.join(cmd), stdout= =3Dsubprocess.PIPE, stderr=3Dsubprocess.PIPE, shell=3DTrue) - except Exception, X: + except Exception as X: EdkLogger.error("GenFw", COMMAND_FAILURE, ExtraData=3D= "%s: %s" % (str(X), cmd[0])) EndOfProcedure =3D threading.Event() EndOfProcedure.clear() diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Pyth= on/build/build.py index de19756d99cb..0379fd8baf1e 100644 --- a/BaseTools/Source/Python/build/build.py +++ b/BaseTools/Source/Python/build/build.py @@ -546,7 +546,7 @@ class BuildTask: EdkLogger.debug(EdkLogger.DEBUG_8, "Threads [%s]" % ", ".j= oin([Th.getName() for Th in threading.enumerate()])) # avoid tense loop time.sleep(0.1) - except BaseException, X: + except BaseException as X: # # TRICK: hide the output of threads left runing, so that the u= ser can # catch the error message easily @@ -1316,7 +1316,7 @@ class Build(): try: #os.rmdir(AutoGenObject.BuildDir) RemoveDirectory(AutoGenObject.BuildDir, True) - except WindowsError, X: + except WindowsError as X: EdkLogger.error("build", FILE_DELETE_FAILURE, ExtraData=3D= str(X)) return True =20 @@ -1406,7 +1406,7 @@ class Build(): try: #os.rmdir(AutoGenObject.BuildDir) RemoveDirectory(AutoGenObject.BuildDir, True) - except WindowsError, X: + except WindowsError as X: EdkLogger.error("build", FILE_DELETE_FAILURE, ExtraData=3D= str(X)) return True =20 @@ -2488,14 +2488,14 @@ def Main(): # All job done, no error found and no exception raised # BuildError =3D False - except FatalError, X: + except FatalError as X: if MyBuild !=3D None: # for multi-thread build exits safely MyBuild.Relinquish() if Option !=3D None and Option.debug !=3D None: EdkLogger.quiet("(Python %s on %s) " % (platform.python_versio= n(), sys.platform) + traceback.format_exc()) ReturnCode =3D X.args[0] - except Warning, X: + except Warning as X: # error from Fdf parser if MyBuild !=3D None: # for multi-thread build exits safely diff --git a/BaseTools/Tests/CheckPythonSyntax.py b/BaseTools/Tests/CheckPy= thonSyntax.py index 61a048ad5d05..a55b29de4713 100644 --- a/BaseTools/Tests/CheckPythonSyntax.py +++ b/BaseTools/Tests/CheckPythonSyntax.py @@ -29,7 +29,7 @@ class Tests(TestTools.BaseToolsTest): def SingleFileTest(self, filename): try: py_compile.compile(filename, doraise=3DTrue) - except Exception, e: + except Exception as e: self.fail('syntax error: %s, Error is %s' % (filename, str(e))) =20 def MakePythonSyntaxCheckTests(): diff --git a/BaseTools/gcc/mingw-gcc-build.py b/BaseTools/gcc/mingw-gcc-bui= ld.py index 420b3dea80f7..858b4020ef9f 100755 --- a/BaseTools/gcc/mingw-gcc-build.py +++ b/BaseTools/gcc/mingw-gcc-build.py @@ -337,7 +337,7 @@ class SourceFiles: print '[KeyboardInterrupt]' return False =20 - except Exception, e: + except Exception as e: print e =20 if not completed: return False --=20 2.15.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel