From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 9233F780091 for ; Wed, 13 Dec 2023 21:20:19 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=7FlZoT3z6Tl4ovq5NjiVVIw+/hHgaMA4EfYYfftv//4=; c=relaxed/simple; d=groups.io; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject:To:Cc:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type; s=20140610; t=1702502418; v=1; b=E2UfszgiiLhj3bV9KPzjIImrTc0P+BKlD8Te+CF4XoQ68BlaAIeQQ812qTNbcHAWNXWwkCOm 3+iBRq1i1ScbAa8XLF3LqE7EKWvQnsf1GqJ4ts2cleIBLP0XMjXT+7qaKs1BBbkQHW2wNK3SBBD SmT6nj+9sBPtN8kLHukaSnkI= X-Received: by 127.0.0.2 with SMTP id PGMEYY7687511xOjKwy4m3B7; Wed, 13 Dec 2023 13:20:18 -0800 X-Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) by mx.groups.io with SMTP id smtpd.web11.950.1702502417588769864 for ; Wed, 13 Dec 2023 13:20:17 -0800 X-Received: by mail-pg1-f178.google.com with SMTP id 41be03b00d2f7-5c690c3d113so6194359a12.1 for ; Wed, 13 Dec 2023 13:20:17 -0800 (PST) X-Gm-Message-State: DBzeujgPnOFXeMoPS2njzFKJx7686176AA= X-Google-Smtp-Source: AGHT+IHRapVtZvu1WghApsd1E27Z5sH99qqm62AKQLw/wCCM4KUyrYB4Sy7vfBFAzq6P6k7B93JvSN8fEyyinagVE3w= X-Received: by 2002:a05:6a20:bb04:b0:18a:f317:1ee8 with SMTP id fc4-20020a056a20bb0400b0018af3171ee8mr9372470pzb.16.1702502416773; Wed, 13 Dec 2023 13:20:16 -0800 (PST) MIME-Version: 1.0 References: <20231206202703.1568-1-joey.vagedes@gmail.com> <20231206202703.1568-2-joey.vagedes@gmail.com> <008301da2c92$575952d0$060bf870$@byosoft.com.cn> In-Reply-To: <008301da2c92$575952d0$060bf870$@byosoft.com.cn> From: "Joey Vagedes via groups.io" Date: Wed, 13 Dec 2023 13:20:04 -0800 Message-ID: Subject: Re: [edk2-devel] [PATCH v1 1/1] BaseTools: Resolve regex syntax warnings To: gaoliming Cc: devel@edk2.groups.io, Rebecca Cran , Bob Feng , Yuwei Chen Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,joeyvagedes@microsoft.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Type: multipart/alternative; boundary="000000000000c7f5f1060c6abbf1" X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=E2Ufszgi; dmarc=none; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io --000000000000c7f5f1060c6abbf1 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello! Raw strings (the r prefix for a string) has been around since python 2, so this change will not break anything. It just ensures that the backwards slash is never treated as an escape character, which is what is expected for regex strings. The only change that occurred is that python 3.12 now displays a syntax warning when it sees an invalid escape character. This is expected for regex strings, which is why it is suggested to use raw strings when creating regex strings. Thanks, Joey On Mon, Dec 11, 2023 at 4:30=E2=80=AFPM gaoliming wrote: > Joey: > Does this change still work on old python version, such as Python 3.9? > > Thanks > Liming > > -----=E9=82=AE=E4=BB=B6=E5=8E=9F=E4=BB=B6----- > > =E5=8F=91=E4=BB=B6=E4=BA=BA: Joey Vagedes > > =E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4: 2023=E5=B9=B412=E6=9C=887=E6=97= =A5 4:27 > > =E6=94=B6=E4=BB=B6=E4=BA=BA: devel@edk2.groups.io > > =E6=8A=84=E9=80=81: Rebecca Cran ; Liming Gao > > ; Bob Feng ; Yuwei Chen > > > > =E4=B8=BB=E9=A2=98: [PATCH v1 1/1] BaseTools: Resolve regex syntax warn= ings > > > > Switches regex patterns to raw text to resolve python 3.12 syntax > > warnings in regards to invalid escape sequences, as is suggested by the > > re (regex) module in python. > > > > Cc: Rebecca Cran > > Cc: Liming Gao > > Cc: Bob Feng > > Cc: Yuwei Chen > > Signed-off-by: Joey Vagedes > > --- > > BaseTools/Source/Python/AmlToC/AmlToC.py | 2 > > +- > > BaseTools/Source/Python/AutoGen/BuildEngine.py | 2 > > +- > > BaseTools/Source/Python/AutoGen/GenDepex.py | > > 2 +- > > BaseTools/Source/Python/AutoGen/GenMake.py | > > 2 +- > > BaseTools/Source/Python/AutoGen/IdfClassObject.py | 2 +- > > BaseTools/Source/Python/AutoGen/ModuleAutoGen.py | 4 > > ++-- > > BaseTools/Source/Python/AutoGen/StrGather.py | 2 > > +- > > BaseTools/Source/Python/AutoGen/WorkspaceAutoGen.py | 2 > > +- > > BaseTools/Source/Python/Common/Expression.py | 16 > > ++++++------- > > BaseTools/Source/Python/Common/GlobalData.py | > > 4 ++-- > > BaseTools/Source/Python/Common/Misc.py | > > 24 ++++++++++---------- > > BaseTools/Source/Python/Common/ToolDefClassObject.py | 6 > > ++--- > > BaseTools/Source/Python/GenFds/FdfParser.py | 10 > > ++++---- > > BaseTools/Source/Python/GenFds/GenFds.py | 2 > > +- > > BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py | 12 > > +++++----- > > BaseTools/Source/Python/Trim/Trim.py | 18 > > +++++++-------- > > BaseTools/Source/Python/Workspace/DscBuildData.py | 8 > > +++---- > > BaseTools/Source/Python/Workspace/MetaFileParser.py | 2 +- > > 18 files changed, 60 insertions(+), 60 deletions(-) > > > > diff --git a/BaseTools/Source/Python/AmlToC/AmlToC.py > > b/BaseTools/Source/Python/AmlToC/AmlToC.py > > index 346de7159de7..63931c9720c9 100644 > > --- a/BaseTools/Source/Python/AmlToC/AmlToC.py > > +++ b/BaseTools/Source/Python/AmlToC/AmlToC.py > > @@ -17,7 +17,7 @@ from Common.BuildToolError import * > > import sys > > > > import os > > > > > > > > -__description__ =3D """ > > > > +__description__ =3D r""" > > > > Convert an AML file to a .c file containing the AML bytecode stored in= a > C > > > > array. By default, Tables\Dsdt.aml will generate Tables\Dsdt.c. > > > > Tables\Dsdt.c will contain a C array named "dsdt_aml_code" that contai= ns > > > > diff --git a/BaseTools/Source/Python/AutoGen/BuildEngine.py > > b/BaseTools/Source/Python/AutoGen/BuildEngine.py > > index 752a1a1f6a86..45b39d7878d5 100644 > > --- a/BaseTools/Source/Python/AutoGen/BuildEngine.py > > +++ b/BaseTools/Source/Python/AutoGen/BuildEngine.py > > @@ -306,7 +306,7 @@ class BuildRule: > > _SubSectionList =3D [_InputFile, _OutputFile, _Command] > > > > > > > > _PATH_SEP =3D "(+)" > > > > - _FileTypePattern =3D re.compile("^[_a-zA-Z][_\-0-9a-zA-Z]*$") > > > > + _FileTypePattern =3D re.compile(r"^[_a-zA-Z][_\-0-9a-zA-Z]*$") > > > > _BinaryFileRule =3D FileBuildRule(TAB_DEFAULT_BINARY_FILE, [], > > [os.path.join("$(OUTPUT_DIR)", "${s_name}")], > > > > ["$(CP) ${src} ${dst}"], []) > > > > > > > > diff --git a/BaseTools/Source/Python/AutoGen/GenDepex.py > > b/BaseTools/Source/Python/AutoGen/GenDepex.py > > index f2f2e9d65b5f..b6db6645a4fb 100644 > > --- a/BaseTools/Source/Python/AutoGen/GenDepex.py > > +++ b/BaseTools/Source/Python/AutoGen/GenDepex.py > > @@ -126,7 +126,7 @@ class DependencyExpression: > > # > > > > # open and close brace must be taken as individual tokens > > > > # > > > > - TokenPattern =3D re.compile("(\(|\)|\{[^{}]+\{?[^{}]+\}?[ ]*\}|\w+= )") > > > > + TokenPattern =3D re.compile(r"(\(|\)|\{[^{}]+\{?[^{}]+\}?[ ]*\}|\w= +)") > > > > > > > > ## Constructor > > > > # > > > > diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py > > b/BaseTools/Source/Python/AutoGen/GenMake.py > > index daec9c6d54b2..c416fe172fe5 100755 > > --- a/BaseTools/Source/Python/AutoGen/GenMake.py > > +++ b/BaseTools/Source/Python/AutoGen/GenMake.py > > @@ -28,7 +28,7 @@ from Common.DataType import TAB_COMPILER_MSFT > > gIncludePattern =3D > > re.compile(r"^[ \t]*[#%]?[ \t]*include(?:[ \t]*(?:\\(?:\r\n|\r|\n))*[ > \t]*)*(?:\( > > ?[\"<]?[ \t]*)([-\w.\\/() \t]+)(?:[ \t]*[\">]?\)?)", re.MULTILINE | > re.UNICODE | > > re.IGNORECASE) > > > > > > > > ## Regular expression for matching macro used in header file inclusion > > > > -gMacroPattern =3D re.compile("([_A-Z][_A-Z0-9]*)[ \t]*\((.+)\)", > re.UNICODE) > > > > +gMacroPattern =3D re.compile(r"([_A-Z][_A-Z0-9]*)[ \t]*\((.+)\)", > re.UNICODE) > > > > > > > > gIsFileMap =3D {} > > > > > > > > diff --git a/BaseTools/Source/Python/AutoGen/IdfClassObject.py > > b/BaseTools/Source/Python/AutoGen/IdfClassObject.py > > index a6b8123c2539..bb413c6a26e3 100644 > > --- a/BaseTools/Source/Python/AutoGen/IdfClassObject.py > > +++ b/BaseTools/Source/Python/AutoGen/IdfClassObject.py > > @@ -18,7 +18,7 @@ import os > > from Common.GlobalData import gIdentifierPattern > > > > from .UniClassObject import StripComments > > > > > > > > -IMAGE_TOKEN =3D re.compile('IMAGE_TOKEN *\(([A-Z0-9_]+) *\)', > > re.MULTILINE | re.UNICODE) > > > > +IMAGE_TOKEN =3D re.compile(r'IMAGE_TOKEN *\(([A-Z0-9_]+) *\)', > > re.MULTILINE | re.UNICODE) > > > > > > > > # > > > > # Value of different image information block types > > > > diff --git a/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py > > b/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py > > index d05410b32966..65a2176ca982 100755 > > --- a/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py > > +++ b/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py > > @@ -51,12 +51,12 @@ gInfSpecVersion =3D "0x00010017" > > # > > > > # Match name =3D variable > > > > # > > > > -gEfiVarStoreNamePattern =3D re.compile("\s*name\s*=3D\s*(\w+)") > > > > +gEfiVarStoreNamePattern =3D re.compile(r"\s*name\s*=3D\s*(\w+)") > > > > # > > > > # The format of guid in efivarstore statement likes following and must > be > > correct: > > > > # guid =3D {0xA04A27f4, 0xDF00, 0x4D42, {0xB5, 0x52, 0x39, 0x51, 0x13, > 0x02, > > 0x11, 0x3D}} > > > > # > > > > -gEfiVarStoreGuidPattern =3D re.compile("\s*guid\s*=3D\s*({.*?{.*?}\s*}= )") > > > > +gEfiVarStoreGuidPattern =3D re.compile(r"\s*guid\s*=3D\s*({.*?{.*?}\s*= })") > > > > > > > > # > > > > # Template string to generic AsBuilt INF > > > > diff --git a/BaseTools/Source/Python/AutoGen/StrGather.py > > b/BaseTools/Source/Python/AutoGen/StrGather.py > > index eed30388bea1..9789f50ba4db 100644 > > --- a/BaseTools/Source/Python/AutoGen/StrGather.py > > +++ b/BaseTools/Source/Python/AutoGen/StrGather.py > > @@ -54,7 +54,7 @@ NOT_REFERENCED =3D 'not referenced' > > COMMENT_NOT_REFERENCED =3D ' ' + COMMENT + NOT_REFERENCED > > > > CHAR_ARRAY_DEFIN =3D 'unsigned char' > > > > COMMON_FILE_NAME =3D 'Strings' > > > > -STRING_TOKEN =3D re.compile('STRING_TOKEN *\(([A-Z0-9_]+) *\)', > > re.MULTILINE | re.UNICODE) > > > > +STRING_TOKEN =3D re.compile(r'STRING_TOKEN *\(([A-Z0-9_]+) *\)', > > re.MULTILINE | re.UNICODE) > > > > > > > > EFI_HII_ARRAY_SIZE_LENGTH =3D 4 > > > > EFI_HII_PACKAGE_HEADER_LENGTH =3D 4 > > > > diff --git a/BaseTools/Source/Python/AutoGen/WorkspaceAutoGen.py > > b/BaseTools/Source/Python/AutoGen/WorkspaceAutoGen.py > > index f86c749c08c3..160e3a3cd321 100644 > > --- a/BaseTools/Source/Python/AutoGen/WorkspaceAutoGen.py > > +++ b/BaseTools/Source/Python/AutoGen/WorkspaceAutoGen.py > > @@ -26,7 +26,7 @@ from Common.Misc import * > > import json > > > > > > > > ## Regular expression for splitting Dependency Expression string into > tokens > > > > -gDepexTokenPattern =3D re.compile("(\(|\)|\w+| \S+\.inf)") > > > > +gDepexTokenPattern =3D re.compile(r"(\(|\)|\w+| \S+\.inf)") > > > > > > > > ## Regular expression for match: PCD(xxxx.yyy) > > > > gPCDAsGuidPattern =3D re.compile(r"^PCD\(.+\..+\)$") > > > > diff --git a/BaseTools/Source/Python/Common/Expression.py > > b/BaseTools/Source/Python/Common/Expression.py > > index b62efe6f9be6..9d9cb0c92962 100644 > > --- a/BaseTools/Source/Python/Common/Expression.py > > +++ b/BaseTools/Source/Python/Common/Expression.py > > @@ -41,8 +41,8 @@ ERR_EMPTY_EXPR =3D 'Empty expression is > > not allowed.' > > ERR_IN_OPERAND =3D 'Macro after IN operator can only be: > > $(FAMILY), $(ARCH), $(TOOL_CHAIN_TAG) and $(TARGET).' > > > > > > > > __ValidString =3D re.compile(r'[_a-zA-Z][_0-9a-zA-Z]*$') > > > > -_ReLabel =3D re.compile('LABEL\((\w+)\)') > > > > -_ReOffset =3D re.compile('OFFSET_OF\((\w+)\)') > > > > +_ReLabel =3D re.compile(r'LABEL\((\w+)\)') > > > > +_ReOffset =3D re.compile(r'OFFSET_OF\((\w+)\)') > > > > PcdPattern =3D > > re.compile(r'^[_a-zA-Z][0-9A-Za-z_]*\.[_a-zA-Z][0-9A-Za-z_]*$') > > > > > > > > ## SplitString > > > > @@ -242,10 +242,10 @@ class ValueExpression(BaseExpression): > > > > > > > > > > SymbolPattern =3D re.compile("(" > > > > - > > "\$\([A-Z][A-Z0-9_]*\)|\$\(\w+\.\w+\)|\w+\.\w+|" > > > > - "&&|\|\||!(?!=3D)|" > > > > - > > "(?<=3D\W)AND(?=3D\W)|(?<=3D\W)OR(?=3D\W)|(?<=3D\W)NOT(?=3D\W)|(?<=3D\W= )XOR(?=3D > > \W)|" > > > > - > > "(?<=3D\W)EQ(?=3D\W)|(?<=3D\W)NE(?=3D\W)|(?<=3D\W)GT(?=3D\W)|(?<=3D\W)L= T(?=3D\W)|( > > ?<=3D\W)GE(?=3D\W)|(?<=3D\W)LE(?=3D\W)" > > > > + > > r"\$\([A-Z][A-Z0-9_]*\)|\$\(\w+\.\w+\)|\w+\.\w+|" > > > > + r"&&|\|\||!(?!=3D)|" > > > > + > > r"(?<=3D\W)AND(?=3D\W)|(?<=3D\W)OR(?=3D\W)|(?<=3D\W)NOT(?=3D\W)|(?<=3D\= W)XOR(? > > =3D\W)|" > > > > + > > r"(?<=3D\W)EQ(?=3D\W)|(?<=3D\W)NE(?=3D\W)|(?<=3D\W)GT(?=3D\W)|(?<=3D\W)= LT(?=3D\W)| > > (?<=3D\W)GE(?=3D\W)|(?<=3D\W)LE(?=3D\W)" > > > > ")") > > > > > > > > @staticmethod > > > > @@ -737,7 +737,7 @@ class ValueExpression(BaseExpression): > > self._Token =3D "'" + UStr + "'" > > > > return self._Token > > > > elif Expr.startswith('UINT'): > > > > - Re =3D re.compile('(?:UINT8|UINT16|UINT32|UINT64)\((.+)\)'= ) > > > > + Re =3D > > re.compile(r'(?:UINT8|UINT16|UINT32|UINT64)\((.+)\)') > > > > try: > > > > RetValue =3D Re.search(Expr).group(1) > > > > except: > > > > @@ -975,7 +975,7 @@ class ValueExpressionEx(ValueExpression): > > TokenSpaceGuidName =3D '' > > > > if Item.startswith(TAB_GUID) and > > Item.endswith(')'): > > > > try: > > > > - TokenSpaceGuidName =3D > > re.search('GUID\((\w+)\)', Item).group(1) > > > > + TokenSpaceGuidName =3D > > re.search(r'GUID\((\w+)\)', Item).group(1) > > > > except: > > > > pass > > > > if TokenSpaceGuidName and > > TokenSpaceGuidName in self._Symb: > > > > diff --git a/BaseTools/Source/Python/Common/GlobalData.py > > b/BaseTools/Source/Python/Common/GlobalData.py > > index 197bd8366682..11849e863f53 100755 > > --- a/BaseTools/Source/Python/Common/GlobalData.py > > +++ b/BaseTools/Source/Python/Common/GlobalData.py > > @@ -33,10 +33,10 @@ gDefaultStores =3D [] > > gGuidDict =3D {} > > > > > > > > # definition for a MACRO name. used to create regular expressions > below. > > > > -_MacroNamePattern =3D "[A-Z][A-Z0-9_]*" > > > > +_MacroNamePattern =3D r"[A-Z][A-Z0-9_]*" > > > > > > > > ## Regular expression for matching macro used in DSC/DEC/INF file > inclusion > > > > -gMacroRefPattern =3D re.compile("\$\(({})\)".format(_MacroNamePattern)= , > > re.UNICODE) > > > > +gMacroRefPattern =3D re.compile(r"\$\(({})\)".format(_MacroNamePattern= ), > > re.UNICODE) > > > > gMacroDefPattern =3D re.compile("^(DEFINE|EDK_GLOBAL)[ \t]+") > > > > gMacroNamePattern =3D re.compile("^{}$".format(_MacroNamePattern)) > > > > > > > > diff --git a/BaseTools/Source/Python/Common/Misc.py > > b/BaseTools/Source/Python/Common/Misc.py > > index 4be7957138a5..f87d9dbdba39 100755 > > --- a/BaseTools/Source/Python/Common/Misc.py > > +++ b/BaseTools/Source/Python/Common/Misc.py > > @@ -41,16 +41,16 @@ from CommonDataClass.Exceptions import > > BadExpression > > from Common.caching import cached_property > > > > import struct > > > > > > > > -ArrayIndex =3D re.compile("\[\s*[0-9a-fA-FxX]*\s*\]") > > > > +ArrayIndex =3D re.compile(r"\[\s*[0-9a-fA-FxX]*\s*\]") > > > > ## Regular expression used to find out place holders in string templat= e > > > > -gPlaceholderPattern =3D re.compile("\$\{([^$()\s]+)\}", re.MULTILINE | > > re.UNICODE) > > > > +gPlaceholderPattern =3D re.compile(r"\$\{([^$()\s]+)\}", re.MULTILINE = | > > re.UNICODE) > > > > > > > > ## regular expressions for map file processing > > > > -startPatternGeneral =3D re.compile("^Start[' ']+Length[' ']+Name[' > ']+Class") > > > > -addressPatternGeneral =3D re.compile("^Address[' ']+Publics by Value[' > > ']+Rva\+Base") > > > > -valuePatternGcc =3D re.compile('^([\w_\.]+) +([\da-fA-Fx]+) > +([\da-fA-Fx]+)$') > > > > -pcdPatternGcc =3D re.compile('^([\da-fA-Fx]+) +([\da-fA-Fx]+)') > > > > -secReGeneral =3D re.compile('^([\da-fA-F]+):([\da-fA-F]+) > +([\da-fA-F]+)[Hh]? > > +([.\w\$]+) +(\w+)', re.UNICODE) > > > > +startPatternGeneral =3D re.compile(r"^Start[' ']+Length[' ']+Name[' > ']+Class") > > > > +addressPatternGeneral =3D re.compile(r"^Address[' ']+Publics by Value[= ' > > ']+Rva\+Base") > > > > +valuePatternGcc =3D re.compile(r'^([\w_\.]+) +([\da-fA-Fx]+) > +([\da-fA-Fx]+)$') > > > > +pcdPatternGcc =3D re.compile(r'^([\da-fA-Fx]+) +([\da-fA-Fx]+)') > > > > +secReGeneral =3D re.compile(r'^([\da-fA-F]+):([\da-fA-F]+) > +([\da-fA-F]+)[Hh]? > > +([.\w\$]+) +(\w+)', re.UNICODE) > > > > > > > > StructPattern =3D re.compile(r'[_a-zA-Z][0-9A-Za-z_]*$') > > > > > > > > @@ -82,7 +82,7 @@ def GetVariableOffset(mapfilepath, efifilepath, > > varnames): > > > > > > if len(lines) =3D=3D 0: return None > > > > firstline =3D lines[0].strip() > > > > - if re.match('^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', > > firstline): > > > > + if re.match(r'^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', > > firstline): > > > > return _parseForXcodeAndClang9(lines, efifilepath, varnames) > > > > if (firstline.startswith("Archive member included ") and > > > > firstline.endswith(" file (symbol)")): > > > > @@ -96,7 +96,7 @@ def _parseForXcodeAndClang9(lines, efifilepath, > > varnames): > > ret =3D [] > > > > for line in lines: > > > > line =3D line.strip() > > > > - if status =3D=3D 0 and > > (re.match('^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', line) \ > > > > + if status =3D=3D 0 and > > (re.match(r'^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', line) = \ > > > > or line =3D=3D "# Symbols:"): > > > > status =3D 1 > > > > continue > > > > @@ -104,7 +104,7 @@ def _parseForXcodeAndClang9(lines, efifilepath, > > varnames): > > for varname in varnames: > > > > if varname in line: > > > > # cannot pregenerate this RegEx since it uses > > varname from varnames. > > > > - m =3D re.match('^([\da-fA-FxX]+)([\s\S]*)([_]*%s)$= ' % > > varname, line) > > > > + m =3D re.match(r'^([\da-fA-FxX]+)([\s\S]*)([_]*%s)= $' % > > varname, line) > > > > if m is not None: > > > > ret.append((varname, m.group(1))) > > > > return ret > > > > @@ -170,7 +170,7 @@ def _parseGeneral(lines, efifilepath, varnames): > > status =3D 0 #0 - beginning of file; 1 - PE section definition;= 2 - > symbol > > table > > > > secs =3D [] # key =3D section name > > > > varoffset =3D [] > > > > - symRe =3D re.compile('^([\da-fA-F]+):([\da-fA-F]+) > +([\.:\\\\\w\?@\$-]+) > > +([\da-fA-F]+)', re.UNICODE) > > > > + symRe =3D re.compile(r'^([\da-fA-F]+):([\da-fA-F]+) > +([\.:\\\\\w\?@\$-]+) > > +([\da-fA-F]+)', re.UNICODE) > > > > > > > > for line in lines: > > > > line =3D line.strip() > > > > @@ -1926,4 +1926,4 @@ def CopyDict(ori_dict): > > # Remove the c/c++ comments: // and /* */ > > > > # > > > > def RemoveCComments(ctext): > > > > - return re.sub('//.*?\n|/\*.*?\*/', '\n', ctext, flags=3Dre.S) > > > > + return re.sub(r'//.*?\n|/\*.*?\*/', '\n', ctext, flags=3Dre.S) > > > > diff --git a/BaseTools/Source/Python/Common/ToolDefClassObject.py > > b/BaseTools/Source/Python/Common/ToolDefClassObject.py > > index 2b4b23849196..afc20a3c1719 100644 > > --- a/BaseTools/Source/Python/Common/ToolDefClassObject.py > > +++ b/BaseTools/Source/Python/Common/ToolDefClassObject.py > > @@ -30,9 +30,9 @@ from .DataType import TAB_TOD_DEFINES_TARGET, > > TAB_TOD_DEFINES_TOOL_CHAIN_TAG,\ > > ## > > > > # Static variables used for pattern > > > > # > > > > -gMacroRefPattern =3D re.compile('(DEF\([^\(\)]+\))') > > > > -gEnvRefPattern =3D re.compile('(ENV\([^\(\)]+\))') > > > > -gMacroDefPattern =3D re.compile("DEFINE\s+([^\s]+)") > > > > +gMacroRefPattern =3D re.compile(r'(DEF\([^\(\)]+\))') > > > > +gEnvRefPattern =3D re.compile(r'(ENV\([^\(\)]+\))') > > > > +gMacroDefPattern =3D re.compile(r"DEFINE\s+([^\s]+)") > > > > gDefaultToolsDefFile =3D "tools_def.txt" > > > > > > > > ## ToolDefClassObject > > > > diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py > > b/BaseTools/Source/Python/GenFds/FdfParser.py > > index a9a14ca2bb33..feb4c727794f 100644 > > --- a/BaseTools/Source/Python/GenFds/FdfParser.py > > +++ b/BaseTools/Source/Python/GenFds/FdfParser.py > > @@ -65,11 +65,11 @@ ALIGNMENTS =3D {"Auto", "8", "16", "32", "64", "128= ", > > "512", "1K", "4K", "32K", "6 > > ALIGNMENT_NOAUTO =3D ALIGNMENTS - {"Auto"} > > > > CR_LB_SET =3D {T_CHAR_CR, TAB_LINE_BREAK} > > > > > > > > -RegionSizePattern =3D > > > compile("\s*(?P(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P(?:0x|0X)?[a= -f > > A-F0-9]+)\s*") > > > > -RegionSizeGuidPattern =3D > > compile("\s*(?P\w+\.\w+[\.\w\[\]]*)\s*\|\s*(?P\w+\.\w+[\.\w > > \[\]]*)\s*") > > > > -RegionOffsetPcdPattern =3D compile("\s*(?P\w+\.\w+[\.\w\[\]]*)\s= *$") > > > > -ShortcutPcdPattern =3D > > compile("\s*\w+\s*=3D\s*(?P(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P > >\w+\.\w+)\s*") > > > > -BaseAddrValuePattern =3D compile('^0[xX][0-9a-fA-F]+') > > > > +RegionSizePattern =3D > > > compile(r"\s*(?P(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P(?:0x|0X)?[= a > > -fA-F0-9]+)\s*") > > > > +RegionSizeGuidPattern =3D > > compile(r"\s*(?P\w+\.\w+[\.\w\[\]]*)\s*\|\s*(?P\w+\.\w+[\.\= w > > \[\]]*)\s*") > > > > +RegionOffsetPcdPattern =3D > > compile(r"\s*(?P\w+\.\w+[\.\w\[\]]*)\s*$") > > > > +ShortcutPcdPattern =3D > > compile(r"\s*\w+\s*=3D\s*(?P(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P > >\w+\.\w+)\s*") > > > > +BaseAddrValuePattern =3D compile(r'^0[xX][0-9a-fA-F]+') > > > > FileExtensionPattern =3D compile(r'([a-zA-Z][a-zA-Z0-9]*)') > > > > TokenFindPattern =3D > > compile(r'([a-zA-Z0-9\-]+|\$\(TARGET\)|\*)_([a-zA-Z0-9\-]+|\$\(TOOL_CHA= I > > N_TAG\)|\*)_([a-zA-Z0-9\-]+|\$\(ARCH\)|\*)') > > > > AllIncludeFileList =3D [] > > > > diff --git a/BaseTools/Source/Python/GenFds/GenFds.py > > b/BaseTools/Source/Python/GenFds/GenFds.py > > index 17b71b7cd347..b48fe761e051 100644 > > --- a/BaseTools/Source/Python/GenFds/GenFds.py > > +++ b/BaseTools/Source/Python/GenFds/GenFds.py > > @@ -733,7 +733,7 @@ class GenFds(object): > > if not os.path.exists(FfsPath[0]): > > > > continue > > > > MatchDict =3D {} > > > > - ReFileEnds =3D > > > > compile('\S+(.ui)$|\S+(fv.sec.txt)$|\S+(.pe32.txt)$|\S+(.te.txt)$|\S+(.pi= c.t > xt)$ > > |\S+(.raw.txt)$|\S+(.ffs.txt)$') > > > > + ReFileEnds =3D > > > > compile(r'\S+(.ui)$|\S+(fv.sec.txt)$|\S+(.pe32.txt)$|\S+(.te.txt)$|\S+(.p= ic. > txt)$ > > |\S+(.raw.txt)$|\S+(.ffs.txt)$') > > > > FileList =3D os.listdir(FfsPath[0]) > > > > for File in FileList: > > > > Match =3D ReFileEnds.search(File) > > > > diff --git > > a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py > > b/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py > > index d962ab0adda7..8750db998ffc 100644 > > --- a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py > > +++ b/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py > > @@ -31,7 +31,7 @@ __copyright__ =3D "Copyright (c) 2008 - 2018, Intel > > Corporation. All rights reserv > > #=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Internal Libraries > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > > > > > > > #=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Code > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > > > -symRe =3D re.compile('^([\da-fA-F]+):([\da-fA-F]+) > +([\.\-:\\\\\w\?@\$<>]+) > > +([\da-fA-F]+)', re.UNICODE) > > > > +symRe =3D re.compile(r'^([\da-fA-F]+):([\da-fA-F]+) > +([\.\-:\\\\\w\?@\$<>]+) > > +([\da-fA-F]+)', re.UNICODE) > > > > > > > > def parsePcdInfoFromMapFile(mapfilepath, efifilepath): > > > > """ Parse map file to get binary patch pcd information > > > > @@ -49,7 +49,7 @@ def parsePcdInfoFromMapFile(mapfilepath, efifilepath)= : > > > > > > if len(lines) =3D=3D 0: return None > > > > firstline =3D lines[0].strip() > > > > - if re.match('^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', > > firstline): > > > > + if re.match(r'^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', > > firstline): > > > > return _parseForXcodeAndClang9(lines, efifilepath) > > > > if (firstline.startswith("Archive member included ") and > > > > firstline.endswith(" file (symbol)")): > > > > @@ -59,12 +59,12 @@ def parsePcdInfoFromMapFile(mapfilepath, > > efifilepath): > > return _parseGeneral(lines, efifilepath) > > > > > > > > def _parseForXcodeAndClang9(lines, efifilepath): > > > > - valuePattern =3D > > re.compile('^([\da-fA-FxX]+)([\s\S]*)([_]*_gPcd_BinaryPatch_([\w]+))') > > > > + valuePattern =3D > > re.compile(r'^([\da-fA-FxX]+)([\s\S]*)([_]*_gPcd_BinaryPatch_([\w]+))') > > > > status =3D 0 > > > > pcds =3D [] > > > > for line in lines: > > > > line =3D line.strip() > > > > - if status =3D=3D 0 and > > (re.match('^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', line) \ > > > > + if status =3D=3D 0 and > > (re.match(r'^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', line) = \ > > > > or line =3D=3D "# Symbols:"): > > > > status =3D 1 > > > > continue > > > > @@ -77,7 +77,7 @@ def _parseForXcodeAndClang9(lines, efifilepath): > > > > > > def _parseForGCC(lines, efifilepath): > > > > """ Parse map file generated by GCC linker """ > > > > - dataPattern =3D re.compile('^.data._gPcd_BinaryPatch_([\w_\d]+)$') > > > > + dataPattern =3D re.compile(r'^.data._gPcd_BinaryPatch_([\w_\d]+)$'= ) > > > > status =3D 0 > > > > imageBase =3D -1 > > > > sections =3D [] > > > > @@ -136,7 +136,7 @@ def _parseGeneral(lines, efifilepath): > > status =3D 0 #0 - beginning of file; 1 - PE section definition;= 2 - > symbol > > table > > > > secs =3D [] # key =3D section name > > > > bPcds =3D [] > > > > - symPattern =3D re.compile('^[_]+gPcd_BinaryPatch_([\w]+)') > > > > + symPattern =3D re.compile(r'^[_]+gPcd_BinaryPatch_([\w]+)') > > > > > > > > for line in lines: > > > > line =3D line.strip() > > > > diff --git a/BaseTools/Source/Python/Trim/Trim.py > > b/BaseTools/Source/Python/Trim/Trim.py > > index 416935df5e90..6d7bc0551026 100644 > > --- a/BaseTools/Source/Python/Trim/Trim.py > > +++ b/BaseTools/Source/Python/Trim/Trim.py > > @@ -28,15 +28,15 @@ __version__ =3D "%prog Version " + > > __version_number__ > > __copyright__ =3D "Copyright (c) 2007-2018, Intel Corporation. All rig= hts > > reserved." > > > > > > > > ## Regular expression for matching Line Control directive like "#line > xxx" > > > > -gLineControlDirective =3D > re.compile('^\s*#(?:line)?\s+([0-9]+)\s+"*([^"]*)"') > > > > +gLineControlDirective =3D > re.compile(r'^\s*#(?:line)?\s+([0-9]+)\s+"*([^"]*)"') > > > > ## Regular expression for matching "typedef struct" > > > > -gTypedefPattern =3D re.compile("^\s*typedef\s+struct(\s+\w+)?\s*[{]*$"= , > > re.MULTILINE) > > > > +gTypedefPattern =3D re.compile(r"^\s*typedef\s+struct(\s+\w+)?\s*[{]*$= ", > > re.MULTILINE) > > > > ## Regular expression for matching "#pragma pack" > > > > -gPragmaPattern =3D re.compile("^\s*#pragma\s+pack", re.MULTILINE) > > > > +gPragmaPattern =3D re.compile(r"^\s*#pragma\s+pack", re.MULTILINE) > > > > ## Regular expression for matching "typedef" > > > > -gTypedef_SinglePattern =3D re.compile("^\s*typedef", re.MULTILINE) > > > > +gTypedef_SinglePattern =3D re.compile(r"^\s*typedef", re.MULTILINE) > > > > ## Regular expression for matching "typedef struct, typedef union, > struct, > > union" > > > > -gTypedef_MulPattern =3D > > re.compile("^\s*(typedef)?\s+(struct|union)(\s+\w+)?\s*[{]*$", > > re.MULTILINE) > > > > +gTypedef_MulPattern =3D > > re.compile(r"^\s*(typedef)?\s+(struct|union)(\s+\w+)?\s*[{]*$", > > re.MULTILINE) > > > > > > > > # > > > > # The following number pattern match will only match if following > criteria is > > met: > > > > @@ -44,14 +44,14 @@ gTypedef_MulPattern =3D > > re.compile("^\s*(typedef)?\s+(struct|union)(\s+\w+)?\s*[{] > > # as the pattern is greedily match, so it is ok for the > gDecNumberPattern > or > > gHexNumberPattern to grab the maximum match > > > > # > > > > ## Regular expression for matching HEX number > > > > -gHexNumberPattern =3D > > > > re.compile("(?<=3D[^a-zA-Z0-9_])(0[xX])([0-9a-fA-F]+)(U(?=3D$|[^a-zA-Z0-9= _]))?") > > > > +gHexNumberPattern =3D > > > > re.compile(r"(?<=3D[^a-zA-Z0-9_])(0[xX])([0-9a-fA-F]+)(U(?=3D$|[^a-zA-Z0-= 9_]))?" > > ) > > > > ## Regular expression for matching decimal number with 'U' postfix > > > > -gDecNumberPattern =3D > > re.compile("(?<=3D[^a-zA-Z0-9_])([0-9]+)U(?=3D$|[^a-zA-Z0-9_])") > > > > +gDecNumberPattern =3D > > re.compile(r"(?<=3D[^a-zA-Z0-9_])([0-9]+)U(?=3D$|[^a-zA-Z0-9_])") > > > > ## Regular expression for matching constant with 'ULL' 'LL' postfix > > > > -gLongNumberPattern =3D > > > re.compile("(?<=3D[^a-zA-Z0-9_])(0[xX][0-9a-fA-F]+|[0-9]+)U?LL(?=3D$|[^a-= zA-Z0 > > -9_])") > > > > +gLongNumberPattern =3D > > > re.compile(r"(?<=3D[^a-zA-Z0-9_])(0[xX][0-9a-fA-F]+|[0-9]+)U?LL(?=3D$|[^a= -zA-Z > > 0-9_])") > > > > > > > > ## Regular expression for matching "Include ()" in asl file > > > > -gAslIncludePattern =3D > re.compile("^(\s*)[iI]nclude\s*\(\"?([^\"\(\)]+)\"\)", > > re.MULTILINE) > > > > +gAslIncludePattern =3D > re.compile(r"^(\s*)[iI]nclude\s*\(\"?([^\"\(\)]+)\"\)", > > re.MULTILINE) > > > > ## Regular expression for matching C style #include "XXX.asl" in asl > file > > > > gAslCIncludePattern =3D > > re.compile(r'^(\s*)#include\s*[<"]\s*([-\\/\w.]+)\s*([>"])', > re.MULTILINE) > > > > ## Patterns used to convert EDK conventions to EDK2 ECP conventions > > > > diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py > > b/BaseTools/Source/Python/Workspace/DscBuildData.py > > index 8fd949dc50b6..817cdbe5f19c 100644 > > --- a/BaseTools/Source/Python/Workspace/DscBuildData.py > > +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py > > @@ -90,7 +90,7 @@ PcdMakefileHeader =3D ''' > > > > > > WindowsCFLAGS =3D 'CFLAGS =3D $(CFLAGS) /wd4200 /wd4034 /wd4101 ' > > > > LinuxCFLAGS =3D 'CFLAGS +=3D -Wno-pointer-to-int-cast -Wno-unused-vari= able ' > > > > -PcdMakefileEnd =3D ''' > > > > +PcdMakefileEnd =3D r''' > > > > !INCLUDE $(BASE_TOOLS_PATH)\Source\C\Makefiles\ms.common > > > > !INCLUDE $(BASE_TOOLS_PATH)\Source\C\Makefiles\ms.app > > > > ''' > > > > @@ -110,7 +110,7 @@ LIBS =3D -lCommon > > variablePattern =3D re.compile(r'[\t\s]*0[xX][a-fA-F0-9]+$') > > > > SkuIdPattern =3D re.compile(r'^[a-zA-Z_][a-zA-Z0-9_]*$') > > > > ## regular expressions for finding decimal and hex numbers > > > > -Pattern =3D re.compile('^[1-9]\d*|0$') > > > > +Pattern =3D re.compile(r'^[1-9]\d*|0$') > > > > HexPattern =3D re.compile(r'0[xX][0-9a-fA-F]+$') > > > > ## Regular expression for finding header file inclusions > > > > from AutoGen.GenMake import gIncludePattern > > > > @@ -2840,7 +2840,7 @@ class DscBuildData(PlatformBuildClassObject): > > # start generating makefile > > > > MakeApp =3D PcdMakefileHeader > > > > if sys.platform =3D=3D "win32": > > > > - MakeApp =3D MakeApp + 'APPFILE =3D %s\%s.exe\n' % > > (self.OutputPath, PcdValueInitName) + 'APPNAME =3D %s\n' % > > (PcdValueInitName) + 'OBJECTS =3D %s\%s.obj %s.obj\n' % (self.OutputPat= h, > > PcdValueInitName, os.path.join(self.OutputPath, PcdValueCommonName)) + > > 'INC =3D ' > > > > + MakeApp =3D MakeApp + r'APPFILE =3D %s\%s.exe\n' % > > (self.OutputPath, PcdValueInitName) + r'APPNAME =3D %s\n' % > > (PcdValueInitName) + r'OBJECTS =3D %s\%s.obj %s.obj\n' % (self.OutputPa= th, > > PcdValueInitName, os.path.join(self.OutputPath, PcdValueCommonName)) + > > 'INC =3D ' > > > > else: > > > > MakeApp =3D MakeApp + PcdGccMakefile > > > > MakeApp =3D MakeApp + 'APPFILE =3D %s/%s\n' % > > (self.OutputPath, PcdValueInitName) + 'APPNAME =3D %s\n' % > > (PcdValueInitName) + 'OBJECTS =3D %s/%s.o %s.o\n' % (self.OutputPath, > > PcdValueInitName, os.path.join(self.OutputPath, PcdValueCommonName)) + = \ > > > > @@ -2950,7 +2950,7 @@ class DscBuildData(PlatformBuildClassObject): > > MakeApp +=3D "$(OBJECTS) : %s\n" % include_file > > > > if sys.platform =3D=3D "win32": > > > > PcdValueCommonPath =3D > > os.path.normpath(mws.join(GlobalData.gGlobalDefines["EDK_TOOLS_PATH"], > > "Source\C\Common\PcdValueCommon.c")) > > > > - MakeApp =3D MakeApp + '%s\PcdValueCommon.c : %s\n' % > > (self.OutputPath, PcdValueCommonPath) > > > > + MakeApp =3D MakeApp + r'%s\PcdValueCommon.c : %s\n' % > > (self.OutputPath, PcdValueCommonPath) > > > > MakeApp =3D MakeApp + '\tcopy /y %s $@\n' % > > (PcdValueCommonPath) > > > > else: > > > > PcdValueCommonPath =3D > > os.path.normpath(mws.join(GlobalData.gGlobalDefines["EDK_TOOLS_PATH"], > > "Source/C/Common/PcdValueCommon.c")) > > > > diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py > > b/BaseTools/Source/Python/Workspace/MetaFileParser.py > > index 3508591b281e..73a1654edb30 100644 > > --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py > > +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py > > @@ -1897,7 +1897,7 @@ class DecParser(MetaFileParser): > > self._SectionType =3D [] > > > > ArchList =3D set() > > > > PrivateList =3D set() > > > > - Line =3D re.sub(',[\s]*', TAB_COMMA_SPLIT, self._CurrentLine) > > > > + Line =3D re.sub(r',[\s]*', TAB_COMMA_SPLIT, self._CurrentLine) > > > > for Item in Line[1:-1].split(TAB_COMMA_SPLIT): > > > > if Item =3D=3D '': > > > > EdkLogger.error("Parser", FORMAT_UNKNOWN_ERROR, > > > > -- > > 2.43.0.windows.1 > > > > -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#112491): https://edk2.groups.io/g/devel/message/112491 Mute This Topic: https://groups.io/mt/103158449/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- --000000000000c7f5f1060c6abbf1 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello!

Raw strings (the r prefix for a = string) has been around since python 2, so this change will not break anyth= ing. It just ensures that the backwards slash is never treated as an escape= character, which is what is expected for regex strings.

The only ch= ange that occurred=C2=A0is that python 3.12 now displays a syntax warning w= hen it sees an invalid escape character. This is expected for regex strings= , which is why it is suggested to use raw strings when creating regex strin= gs.

Thanks,
Joey

On Mon, Dec 11, 20= 23 at 4:30=E2=80=AFPM gaoliming <gaoliming@byosoft.com.cn> wrote:
Joey:
=C2=A0 Does this change still work on old python version, such as Python 3.= 9?

Thanks
Liming
> -----=E9=82=AE=E4=BB=B6=E5=8E=9F=E4=BB=B6-----
> =E5=8F=91=E4=BB=B6=E4=BA=BA: Joey Vagedes <joey.vagedes@gmail.com>
> =E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4: 2023=E5=B9=B412=E6=9C=887=E6=97= =A5 4:27
> =E6=94=B6=E4=BB=B6=E4=BA=BA: devel@edk2.groups.io
> =E6=8A=84=E9=80=81: Rebecca Cran <rebecca@bsdio.com>; Liming Gao
> <gaol= iming@byosoft.com.cn>; Bob Feng <bob.c.feng@intel.com>; Yuwei Chen
> <yuwei.ch= en@intel.com>
> =E4=B8=BB=E9=A2=98: [PATCH v1 1/1] BaseTools: Resolve regex syntax war= nings
>
> Switches regex patterns to raw text to resolve python 3.12 syntax
> warnings in regards to invalid escape sequences, as is suggested by th= e
> re (regex) module in python.
>
> Cc: Rebecca Cran <rebecca@bsdio.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> Cc: Bob Feng <bob.c.feng@intel.com>
> Cc: Yuwei Chen <yuwei.chen@intel.com>
> Signed-off-by: Joey Vagedes <joey.vagedes@gmail.com>
> ---
>=C2=A0 BaseTools/Source/Python/AmlToC/AmlToC.py=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|=C2=A0 2
> +-
>=C2=A0 BaseTools/Source/Python/AutoGen/BuildEngine.py=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|=C2=A0 2
> +-
>=C2=A0 BaseTools/Source/Python/AutoGen/GenDepex.py=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |
> 2 +-
>=C2=A0 BaseTools/Source/Python/AutoGen/GenMake.py=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|
> 2 +-
>=C2=A0 BaseTools/Source/Python/AutoGen/IdfClassObject.py=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 |=C2=A0 2 +-
>=C2=A0 BaseTools/Source/Python/AutoGen/ModuleAutoGen.py=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|=C2=A0 4
> ++--
>=C2=A0 BaseTools/Source/Python/AutoGen/StrGather.py=C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|=C2=A0 2
> +-
>=C2=A0 BaseTools/Source/Python/AutoGen/WorkspaceAutoGen.py=C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 |=C2=A0 2
> +-
>=C2=A0 BaseTools/Source/Python/Common/Expression.py=C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| 16
> ++++++-------
>=C2=A0 BaseTools/Source/Python/Common/GlobalData.py=C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|
> 4 ++--
>=C2=A0 BaseTools/Source/Python/Common/Misc.py=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|
> 24 ++++++++++----------
>=C2=A0 BaseTools/Source/Python/Common/ToolDefClassObject.py=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0|=C2=A0 6
> ++---
>=C2=A0 BaseTools/Source/Python/GenFds/FdfParser.py=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | 10
> ++++----
>=C2=A0 BaseTools/Source/Python/GenFds/GenFds.py=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|=C2=A0 2
> +-
>=C2=A0 BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py | 1= 2
> +++++-----
>=C2=A0 BaseTools/Source/Python/Trim/Trim.py=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| 18
> +++++++--------
>=C2=A0 BaseTools/Source/Python/Workspace/DscBuildData.py=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 |=C2=A0 8
> +++----
>=C2=A0 BaseTools/Source/Python/Workspace/MetaFileParser.py=C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 |=C2=A0 2 +-
>=C2=A0 18 files changed, 60 insertions(+), 60 deletions(-)
>
> diff --git a/BaseTools/Source/Python/AmlToC/AmlToC.py
> b/BaseTools/Source/Python/AmlToC/AmlToC.py
> index 346de7159de7..63931c9720c9 100644
> --- a/BaseTools/Source/Python/AmlToC/AmlToC.py
> +++ b/BaseTools/Source/Python/AmlToC/AmlToC.py
> @@ -17,7 +17,7 @@ from Common.BuildToolError import *
>=C2=A0 import sys
>
>=C2=A0 import os
>
>
>
> -__description__ =3D """
>
> +__description__ =3D r"""
>
>=C2=A0 Convert an AML file to a .c file containing the AML bytecode sto= red in a
C
>
>=C2=A0 array. By default, Tables\Dsdt.aml will generate Tables\Dsdt.c.<= br> >
>=C2=A0 Tables\Dsdt.c will contain a C array named "dsdt_aml_code&q= uot; that contains
>
> diff --git a/BaseTools/Source/Python/AutoGen/BuildEngine.py
> b/BaseTools/Source/Python/AutoGen/BuildEngine.py
> index 752a1a1f6a86..45b39d7878d5 100644
> --- a/BaseTools/Source/Python/AutoGen/BuildEngine.py
> +++ b/BaseTools/Source/Python/AutoGen/BuildEngine.py
> @@ -306,7 +306,7 @@ class BuildRule:
>=C2=A0 =C2=A0 =C2=A0 _SubSectionList =3D [_InputFile, _OutputFile, _Com= mand]
>
>
>
>=C2=A0 =C2=A0 =C2=A0 _PATH_SEP =3D "(+)"
>
> -=C2=A0 =C2=A0 _FileTypePattern =3D re.compile("^[_a-zA-Z][_\-0-9= a-zA-Z]*$")
>
> +=C2=A0 =C2=A0 _FileTypePattern =3D re.compile(r"^[_a-zA-Z][_\-0-= 9a-zA-Z]*$")
>
>=C2=A0 =C2=A0 =C2=A0 _BinaryFileRule =3D FileBuildRule(TAB_DEFAULT_BINA= RY_FILE, [],
> [os.path.join("$(OUTPUT_DIR)", "${s_name}")],
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ["$(CP)= ${src} ${dst}"], [])
>
>
>
> diff --git a/BaseTools/Source/Python/AutoGen/GenDepex.py
> b/BaseTools/Source/Python/AutoGen/GenDepex.py
> index f2f2e9d65b5f..b6db6645a4fb 100644
> --- a/BaseTools/Source/Python/AutoGen/GenDepex.py
> +++ b/BaseTools/Source/Python/AutoGen/GenDepex.py
> @@ -126,7 +126,7 @@ class DependencyExpression:
>=C2=A0 =C2=A0 =C2=A0 #
>
>=C2=A0 =C2=A0 =C2=A0 # open and close brace must be taken as individual= tokens
>
>=C2=A0 =C2=A0 =C2=A0 #
>
> -=C2=A0 =C2=A0 TokenPattern =3D re.compile("(\(|\)|\{[^{}]+\{?[^{= }]+\}?[ ]*\}|\w+)")
>
> +=C2=A0 =C2=A0 TokenPattern =3D re.compile(r"(\(|\)|\{[^{}]+\{?[^= {}]+\}?[ ]*\}|\w+)")
>
>
>
>=C2=A0 =C2=A0 =C2=A0 ## Constructor
>
>=C2=A0 =C2=A0 =C2=A0 #
>
> diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py
> b/BaseTools/Source/Python/AutoGen/GenMake.py
> index daec9c6d54b2..c416fe172fe5 100755
> --- a/BaseTools/Source/Python/AutoGen/GenMake.py
> +++ b/BaseTools/Source/Python/AutoGen/GenMake.py
> @@ -28,7 +28,7 @@ from Common.DataType import TAB_COMPILER_MSFT
>=C2=A0 gIncludePattern =3D
> re.compile(r"^[ \t]*[#%]?[ \t]*include(?:[ \t]*(?:\\(?:\r\n|\r|\n= ))*[
\t]*)*(?:\(
> ?[\"<]?[ \t]*)([-\w.\\/() \t]+)(?:[ \t]*[\">]?\)?)&quo= t;, re.MULTILINE |
re.UNICODE |
> re.IGNORECASE)
>
>
>
>=C2=A0 ## Regular expression for matching macro used in header file inc= lusion
>
> -gMacroPattern =3D re.compile("([_A-Z][_A-Z0-9]*)[ \t]*\((.+)\)&q= uot;,
re.UNICODE)
>
> +gMacroPattern =3D re.compile(r"([_A-Z][_A-Z0-9]*)[ \t]*\((.+)\)&= quot;,
re.UNICODE)
>
>
>
>=C2=A0 gIsFileMap =3D {}
>
>
>
> diff --git a/BaseTools/Source/Python/AutoGen/IdfClassObject.py
> b/BaseTools/Source/Python/AutoGen/IdfClassObject.py
> index a6b8123c2539..bb413c6a26e3 100644
> --- a/BaseTools/Source/Python/AutoGen/IdfClassObject.py
> +++ b/BaseTools/Source/Python/AutoGen/IdfClassObject.py
> @@ -18,7 +18,7 @@ import os
>=C2=A0 from Common.GlobalData import gIdentifierPattern
>
>=C2=A0 from .UniClassObject import StripComments
>
>
>
> -IMAGE_TOKEN =3D re.compile('IMAGE_TOKEN *\(([A-Z0-9_]+) *\)',=
> re.MULTILINE | re.UNICODE)
>
> +IMAGE_TOKEN =3D re.compile(r'IMAGE_TOKEN *\(([A-Z0-9_]+) *\)'= ,
> re.MULTILINE | re.UNICODE)
>
>
>
>=C2=A0 #
>
>=C2=A0 # Value of different image information block types
>
> diff --git a/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py
> b/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py
> index d05410b32966..65a2176ca982 100755
> --- a/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py
> +++ b/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py
> @@ -51,12 +51,12 @@ gInfSpecVersion =3D "0x00010017"
>=C2=A0 #
>
>=C2=A0 # Match name =3D variable
>
>=C2=A0 #
>
> -gEfiVarStoreNamePattern =3D re.compile("\s*name\s*=3D\s*(\w+)&qu= ot;)
>
> +gEfiVarStoreNamePattern =3D re.compile(r"\s*name\s*=3D\s*(\w+)&q= uot;)
>
>=C2=A0 #
>
>=C2=A0 # The format of guid in efivarstore statement likes following an= d must be
> correct:
>
>=C2=A0 # guid =3D {0xA04A27f4, 0xDF00, 0x4D42, {0xB5, 0x52, 0x39, 0x51,= 0x13,
0x02,
> 0x11, 0x3D}}
>
>=C2=A0 #
>
> -gEfiVarStoreGuidPattern =3D re.compile("\s*guid\s*=3D\s*({.*?{.*= ?}\s*})")
>
> +gEfiVarStoreGuidPattern =3D re.compile(r"\s*guid\s*=3D\s*({.*?{.= *?}\s*})")
>
>
>
>=C2=A0 #
>
>=C2=A0 # Template string to generic AsBuilt INF
>
> diff --git a/BaseTools/Source/Python/AutoGen/StrGather.py
> b/BaseTools/Source/Python/AutoGen/StrGather.py
> index eed30388bea1..9789f50ba4db 100644
> --- a/BaseTools/Source/Python/AutoGen/StrGather.py
> +++ b/BaseTools/Source/Python/AutoGen/StrGather.py
> @@ -54,7 +54,7 @@ NOT_REFERENCED =3D 'not referenced'
>=C2=A0 COMMENT_NOT_REFERENCED =3D ' ' + COMMENT + NOT_REFERENCE= D
>
>=C2=A0 CHAR_ARRAY_DEFIN =3D 'unsigned char'
>
>=C2=A0 COMMON_FILE_NAME =3D 'Strings'
>
> -STRING_TOKEN =3D re.compile('STRING_TOKEN *\(([A-Z0-9_]+) *\)'= ;,
> re.MULTILINE | re.UNICODE)
>
> +STRING_TOKEN =3D re.compile(r'STRING_TOKEN *\(([A-Z0-9_]+) *\)= 9;,
> re.MULTILINE | re.UNICODE)
>
>
>
>=C2=A0 EFI_HII_ARRAY_SIZE_LENGTH =3D 4
>
>=C2=A0 EFI_HII_PACKAGE_HEADER_LENGTH =3D 4
>
> diff --git a/BaseTools/Source/Python/AutoGen/WorkspaceAutoGen.py
> b/BaseTools/Source/Python/AutoGen/WorkspaceAutoGen.py
> index f86c749c08c3..160e3a3cd321 100644
> --- a/BaseTools/Source/Python/AutoGen/WorkspaceAutoGen.py
> +++ b/BaseTools/Source/Python/AutoGen/WorkspaceAutoGen.py
> @@ -26,7 +26,7 @@ from Common.Misc import *
>=C2=A0 import json
>
>
>
>=C2=A0 ## Regular expression for splitting Dependency Expression string= into
tokens
>
> -gDepexTokenPattern =3D re.compile("(\(|\)|\w+| \S+\.inf)")<= br> >
> +gDepexTokenPattern =3D re.compile(r"(\(|\)|\w+| \S+\.inf)")=
>
>
>
>=C2=A0 ## Regular expression for match: PCD(xxxx.yyy)
>
>=C2=A0 gPCDAsGuidPattern =3D re.compile(r"^PCD\(.+\..+\)$") >
> diff --git a/BaseTools/Source/Python/Common/Expression.py
> b/BaseTools/Source/Python/Common/Expression.py
> index b62efe6f9be6..9d9cb0c92962 100644
> --- a/BaseTools/Source/Python/Common/Expression.py
> +++ b/BaseTools/Source/Python/Common/Expression.py
> @@ -41,8 +41,8 @@ ERR_EMPTY_EXPR=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =3D= 'Empty expression is
> not allowed.'
>=C2=A0 ERR_IN_OPERAND=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =3D 'Macro = after IN operator can only be:
> $(FAMILY), $(ARCH), $(TOOL_CHAIN_TAG) and $(TARGET).'
>
>
>
>=C2=A0 __ValidString =3D re.compile(r'[_a-zA-Z][_0-9a-zA-Z]*$')=
>
> -_ReLabel =3D re.compile('LABEL\((\w+)\)')
>
> -_ReOffset =3D re.compile('OFFSET_OF\((\w+)\)')
>
> +_ReLabel =3D re.compile(r'LABEL\((\w+)\)')
>
> +_ReOffset =3D re.compile(r'OFFSET_OF\((\w+)\)')
>
>=C2=A0 PcdPattern =3D
> re.compile(r'^[_a-zA-Z][0-9A-Za-z_]*\.[_a-zA-Z][0-9A-Za-z_]*$'= )
>
>
>
>=C2=A0 ## SplitString
>
> @@ -242,10 +242,10 @@ class ValueExpression(BaseExpression):
>
>
>
>
>=C2=A0 =C2=A0 =C2=A0 SymbolPattern =3D re.compile("("
>
> -
> "\$\([A-Z][A-Z0-9_]*\)|\$\(\w+\.\w+\)|\w+\.\w+|"
>
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"&&|\|\||!(?!= =3D)|"
>
> -
> "(?<=3D\W)AND(?=3D\W)|(?<=3D\W)OR(?=3D\W)|(?<=3D\W)NOT(?= =3D\W)|(?<=3D\W)XOR(?=3D
> \W)|"
>
> -
> "(?<=3D\W)EQ(?=3D\W)|(?<=3D\W)NE(?=3D\W)|(?<=3D\W)GT(?= =3D\W)|(?<=3D\W)LT(?=3D\W)|(
> ?<=3D\W)GE(?=3D\W)|(?<=3D\W)LE(?=3D\W)"
>
> +
> r"\$\([A-Z][A-Z0-9_]*\)|\$\(\w+\.\w+\)|\w+\.\w+|"
>
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0r"&&|\|\||!(?= !=3D)|"
>
> +
> r"(?<=3D\W)AND(?=3D\W)|(?<=3D\W)OR(?=3D\W)|(?<=3D\W)NOT(= ?=3D\W)|(?<=3D\W)XOR(?
> =3D\W)|"
>
> +
> r"(?<=3D\W)EQ(?=3D\W)|(?<=3D\W)NE(?=3D\W)|(?<=3D\W)GT(?= =3D\W)|(?<=3D\W)LT(?=3D\W)|
> (?<=3D\W)GE(?=3D\W)|(?<=3D\W)LE(?=3D\W)"
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0")")
>
>
>
>=C2=A0 =C2=A0 =C2=A0 @staticmethod
>
> @@ -737,7 +737,7 @@ class ValueExpression(BaseExpression):
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self._Token =3D "= '" + UStr + "'"
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return self._Token
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 elif Expr.startswith('UINT')= :
>
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Re =3D re.compile('(?:U= INT8|UINT16|UINT32|UINT64)\((.+)\)')
>
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Re =3D
> re.compile(r'(?:UINT8|UINT16|UINT32|UINT64)\((.+)\)')
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 try:
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 RetValue= =3D Re.search(Expr).group(1)
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 except:
>
> @@ -975,7 +975,7 @@ class ValueExpressionEx(ValueExpression):
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 TokenSpaceGuidName =3D = 9;'
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if Item.startswith(TAB_GUI= D) and
> Item.endswith(')'):
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 try:
>
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Toke= nSpaceGuidName =3D
> re.search('GUID\((\w+)\)', Item).group(1)
>
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Toke= nSpaceGuidName =3D
> re.search(r'GUID\((\w+)\)', Item).group(1)
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 except:
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 pass
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if TokenSpac= eGuidName and
> TokenSpaceGuidName in self._Symb:
>
> diff --git a/BaseTools/Source/Python/Common/GlobalData.py
> b/BaseTools/Source/Python/Common/GlobalData.py
> index 197bd8366682..11849e863f53 100755
> --- a/BaseTools/Source/Python/Common/GlobalData.py
> +++ b/BaseTools/Source/Python/Common/GlobalData.py
> @@ -33,10 +33,10 @@ gDefaultStores =3D []
>=C2=A0 gGuidDict =3D {}
>
>
>
>=C2=A0 # definition for a MACRO name.=C2=A0 used to create regular expr= essions below.
>
> -_MacroNamePattern =3D "[A-Z][A-Z0-9_]*"
>
> +_MacroNamePattern =3D r"[A-Z][A-Z0-9_]*"
>
>
>
>=C2=A0 ## Regular expression for matching macro used in DSC/DEC/INF fil= e
inclusion
>
> -gMacroRefPattern =3D re.compile("\$\(({})\)".format(_MacroN= amePattern),
> re.UNICODE)
>
> +gMacroRefPattern =3D re.compile(r"\$\(({})\)".format(_Macro= NamePattern),
> re.UNICODE)
>
>=C2=A0 gMacroDefPattern =3D re.compile("^(DEFINE|EDK_GLOBAL)[ \t]+= ")
>
>=C2=A0 gMacroNamePattern =3D re.compile("^{}$".format(_MacroN= amePattern))
>
>
>
> diff --git a/BaseTools/Source/Python/Common/Misc.py
> b/BaseTools/Source/Python/Common/Misc.py
> index 4be7957138a5..f87d9dbdba39 100755
> --- a/BaseTools/Source/Python/Common/Misc.py
> +++ b/BaseTools/Source/Python/Common/Misc.py
> @@ -41,16 +41,16 @@ from CommonDataClass.Exceptions import
> BadExpression
>=C2=A0 from Common.caching import cached_property
>
>=C2=A0 import struct
>
>
>
> -ArrayIndex =3D re.compile("\[\s*[0-9a-fA-FxX]*\s*\]")
>
> +ArrayIndex =3D re.compile(r"\[\s*[0-9a-fA-FxX]*\s*\]")
>
>=C2=A0 ## Regular expression used to find out place holders in string t= emplate
>
> -gPlaceholderPattern =3D re.compile("\$\{([^$()\s]+)\}", re.= MULTILINE |
> re.UNICODE)
>
> +gPlaceholderPattern =3D re.compile(r"\$\{([^$()\s]+)\}", re= .MULTILINE |
> re.UNICODE)
>
>
>
>=C2=A0 ## regular expressions for map file processing
>
> -startPatternGeneral =3D re.compile("^Start[' ']+Length[&= #39; ']+Name['
']+Class")
>
> -addressPatternGeneral =3D re.compile("^Address[' ']+Publ= ics by Value['
> ']+Rva\+Base")
>
> -valuePatternGcc =3D re.compile('^([\w_\.]+) +([\da-fA-Fx]+)
+([\da-fA-Fx]+)$')
>
> -pcdPatternGcc =3D re.compile('^([\da-fA-Fx]+) +([\da-fA-Fx]+)'= ;)
>
> -secReGeneral =3D re.compile('^([\da-fA-F]+):([\da-fA-F]+)
+([\da-fA-F]+)[Hh]?
> +([.\w\$]+) +(\w+)', re.UNICODE)
>
> +startPatternGeneral =3D re.compile(r"^Start[' ']+Length[= ' ']+Name['
']+Class")
>
> +addressPatternGeneral =3D re.compile(r"^Address[' ']+Pub= lics by Value['
> ']+Rva\+Base")
>
> +valuePatternGcc =3D re.compile(r'^([\w_\.]+) +([\da-fA-Fx]+)
+([\da-fA-Fx]+)$')
>
> +pcdPatternGcc =3D re.compile(r'^([\da-fA-Fx]+) +([\da-fA-Fx]+)= 9;)
>
> +secReGeneral =3D re.compile(r'^([\da-fA-F]+):([\da-fA-F]+)
+([\da-fA-F]+)[Hh]?
> +([.\w\$]+) +(\w+)', re.UNICODE)
>
>
>
>=C2=A0 StructPattern =3D re.compile(r'[_a-zA-Z][0-9A-Za-z_]*$')=
>
>
>
> @@ -82,7 +82,7 @@ def GetVariableOffset(mapfilepath, efifilepath,
> varnames):
>
>
>=C2=A0 =C2=A0 =C2=A0 if len(lines) =3D=3D 0: return None
>
>=C2=A0 =C2=A0 =C2=A0 firstline =3D lines[0].strip()
>
> -=C2=A0 =C2=A0 if re.match('^\s*Address\s*Size\s*Align\s*Out\s*In\= s*Symbol\s*$',
> firstline):
>
> +=C2=A0 =C2=A0 if re.match(r'^\s*Address\s*Size\s*Align\s*Out\s*In= \s*Symbol\s*$',
> firstline):
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return _parseForXcodeAndClang9(lines= , efifilepath, varnames)
>
>=C2=A0 =C2=A0 =C2=A0 if (firstline.startswith("Archive member incl= uded ") and
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 firstline.endswith(" file (symb= ol)")):
>
> @@ -96,7 +96,7 @@ def _parseForXcodeAndClang9(lines, efifilepath,
> varnames):
>=C2=A0 =C2=A0 =C2=A0 ret =3D []
>
>=C2=A0 =C2=A0 =C2=A0 for line in lines:
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 line =3D line.strip()
>
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 if status =3D=3D 0 and
> (re.match('^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$'= , line) \
>
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 if status =3D=3D 0 and
> (re.match(r'^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$'= ;, line) \
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 or line =3D=3D "#= Symbols:"):
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 status =3D 1
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 continue
>
> @@ -104,7 +104,7 @@ def _parseForXcodeAndClang9(lines, efifilepath, > varnames):
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 for varname in varname= s:
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if varna= me in line:
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 # cannot pregenerate this RegEx since it uses
> varname from varnames.
>
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= m =3D re.match('^([\da-fA-FxX]+)([\s\S]*)([_]*%s)$' %
> varname, line)
>
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= m =3D re.match(r'^([\da-fA-FxX]+)([\s\S]*)([_]*%s)$' %
> varname, line)
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 if m is not None:
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 ret.append((varname, m.group(1)))
>
>=C2=A0 =C2=A0 =C2=A0 return ret
>
> @@ -170,7 +170,7 @@ def _parseGeneral(lines, efifilepath, varnames): >=C2=A0 =C2=A0 =C2=A0 status =3D 0=C2=A0 =C2=A0 #0 - beginning of file; = 1 - PE section definition; 2 -
symbol
> table
>
>=C2=A0 =C2=A0 =C2=A0 secs=C2=A0 =3D []=C2=A0 =C2=A0 # key =3D section n= ame
>
>=C2=A0 =C2=A0 =C2=A0 varoffset =3D []
>
> -=C2=A0 =C2=A0 symRe =3D re.compile('^([\da-fA-F]+):([\da-fA-F]+)<= br> +([\.:\\\\\w\?@\$-]+)
> +([\da-fA-F]+)', re.UNICODE)
>
> +=C2=A0 =C2=A0 symRe =3D re.compile(r'^([\da-fA-F]+):([\da-fA-F]+)=
+([\.:\\\\\w\?@\$-]+)
> +([\da-fA-F]+)', re.UNICODE)
>
>
>
>=C2=A0 =C2=A0 =C2=A0 for line in lines:
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 line =3D line.strip()
>
> @@ -1926,4 +1926,4 @@ def CopyDict(ori_dict):
>=C2=A0 # Remove the c/c++ comments: // and /* */
>
>=C2=A0 #
>
>=C2=A0 def RemoveCComments(ctext):
>
> -=C2=A0 =C2=A0 return re.sub('//.*?\n|/\*.*?\*/', '\n'= , ctext, flags=3Dre.S)
>
> +=C2=A0 =C2=A0 return re.sub(r'//.*?\n|/\*.*?\*/', '\n'= ;, ctext, flags=3Dre.S)
>
> diff --git a/BaseTools/Source/Python/Common/ToolDefClassObject.py
> b/BaseTools/Source/Python/Common/ToolDefClassObject.py
> index 2b4b23849196..afc20a3c1719 100644
> --- a/BaseTools/Source/Python/Common/ToolDefClassObject.py
> +++ b/BaseTools/Source/Python/Common/ToolDefClassObject.py
> @@ -30,9 +30,9 @@ from .DataType import TAB_TOD_DEFINES_TARGET,
> TAB_TOD_DEFINES_TOOL_CHAIN_TAG,\
>=C2=A0 ##
>
>=C2=A0 # Static variables used for pattern
>
>=C2=A0 #
>
> -gMacroRefPattern =3D re.compile('(DEF\([^\(\)]+\))')
>
> -gEnvRefPattern =3D re.compile('(ENV\([^\(\)]+\))')
>
> -gMacroDefPattern =3D re.compile("DEFINE\s+([^\s]+)")
>
> +gMacroRefPattern =3D re.compile(r'(DEF\([^\(\)]+\))')
>
> +gEnvRefPattern =3D re.compile(r'(ENV\([^\(\)]+\))')
>
> +gMacroDefPattern =3D re.compile(r"DEFINE\s+([^\s]+)")
>
>=C2=A0 gDefaultToolsDefFile =3D "tools_def.txt"
>
>
>
>=C2=A0 ## ToolDefClassObject
>
> diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py
> b/BaseTools/Source/Python/GenFds/FdfParser.py
> index a9a14ca2bb33..feb4c727794f 100644
> --- a/BaseTools/Source/Python/GenFds/FdfParser.py
> +++ b/BaseTools/Source/Python/GenFds/FdfParser.py
> @@ -65,11 +65,11 @@ ALIGNMENTS =3D {"Auto", "8", &= quot;16", "32", "64", "128",
> "512", "1K", "4K", "32K", &quo= t;6
>=C2=A0 ALIGNMENT_NOAUTO =3D ALIGNMENTS - {"Auto"}
>
>=C2=A0 CR_LB_SET =3D {T_CHAR_CR, TAB_LINE_BREAK}
>
>
>
> -RegionSizePattern =3D
>
compile("\s*(?P<base>(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P<size&= gt;(?:0x|0X)?[a-f
> A-F0-9]+)\s*")
>
> -RegionSizeGuidPattern =3D
> compile("\s*(?P<base>\w+\.\w+[\.\w\[\]]*)\s*\|\s*(?P<siz= e>\w+\.\w+[\.\w
> \[\]]*)\s*")
>
> -RegionOffsetPcdPattern =3D compile("\s*(?P<base>\w+\.\w+[\= .\w\[\]]*)\s*$")
>
> -ShortcutPcdPattern =3D
> compile("\s*\w+\s*=3D\s*(?P<value>(?:0x|0X)?[a-fA-F0-9]+)\s= *\|\s*(?P<name
> >\w+\.\w+)\s*")
>
> -BaseAddrValuePattern =3D compile('^0[xX][0-9a-fA-F]+')
>
> +RegionSizePattern =3D
> compile(r"\s*(?P<base>(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P<= ;size>(?:0x|0X)?[a
> -fA-F0-9]+)\s*")
>
> +RegionSizeGuidPattern =3D
> compile(r"\s*(?P<base>\w+\.\w+[\.\w\[\]]*)\s*\|\s*(?P<si= ze>\w+\.\w+[\.\w
> \[\]]*)\s*")
>
> +RegionOffsetPcdPattern =3D
> compile(r"\s*(?P<base>\w+\.\w+[\.\w\[\]]*)\s*$")
>
> +ShortcutPcdPattern =3D
> compile(r"\s*\w+\s*=3D\s*(?P<value>(?:0x|0X)?[a-fA-F0-9]+)\= s*\|\s*(?P<name
> >\w+\.\w+)\s*")
>
> +BaseAddrValuePattern =3D compile(r'^0[xX][0-9a-fA-F]+')
>
>=C2=A0 FileExtensionPattern =3D compile(r'([a-zA-Z][a-zA-Z0-9]*)= 9;)
>
>=C2=A0 TokenFindPattern =3D
> compile(r'([a-zA-Z0-9\-]+|\$\(TARGET\)|\*)_([a-zA-Z0-9\-]+|\$\(TOO= L_CHAI
> N_TAG\)|\*)_([a-zA-Z0-9\-]+|\$\(ARCH\)|\*)')
>
>=C2=A0 AllIncludeFileList =3D []
>
> diff --git a/BaseTools/Source/Python/GenFds/GenFds.py
> b/BaseTools/Source/Python/GenFds/GenFds.py
> index 17b71b7cd347..b48fe761e051 100644
> --- a/BaseTools/Source/Python/GenFds/GenFds.py
> +++ b/BaseTools/Source/Python/GenFds/GenFds.py
> @@ -733,7 +733,7 @@ class GenFds(object):
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 if not os.path.exists(FfsPath[0]):
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 continue
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 MatchDict =3D {}
>
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 ReFileEnds =3D
>
compile('\S+(.ui)$|\S+(fv.sec.txt)$|\S+(.pe32.txt)$|\S+(.te.txt)$|\S+(.= pic.t
xt)$
> |\S+(.raw.txt)$|\S+(.ffs.txt)$')
>
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 ReFileEnds =3D
>
compile(r'\S+(.ui)$|\S+(fv.sec.txt)$|\S+(.pe32.txt)$|\S+(.te.txt)$|\S+(= .pic.
txt)$
> |\S+(.raw.txt)$|\S+(.ffs.txt)$')
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 FileList =3D os.listdir(FfsPath[0])
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 for File in FileList:
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Match =3D ReFileEnds.search(File)
>
> diff --git
> a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
> b/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
> index d962ab0adda7..8750db998ffc 100644
> --- a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
> +++ b/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
> @@ -31,7 +31,7 @@ __copyright__ =3D "Copyright (c) 2008 - 2018, I= ntel
> Corporation. All rights reserv
>=C2=A0 #=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=C2=A0 Internal Librarie= s
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>
>
>
>=C2=A0 #=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= Code
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >
> -symRe =3D re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\.\-:\\\\\w= \?@\$<>]+)
> +([\da-fA-F]+)', re.UNICODE)
>
> +symRe =3D re.compile(r'^([\da-fA-F]+):([\da-fA-F]+)
+([\.\-:\\\\\w\?@\$<>]+)
> +([\da-fA-F]+)', re.UNICODE)
>
>
>
>=C2=A0 def parsePcdInfoFromMapFile(mapfilepath, efifilepath):
>
>=C2=A0 =C2=A0 =C2=A0 """ Parse map file to get binary pa= tch pcd information
>
> @@ -49,7 +49,7 @@ def parsePcdInfoFromMapFile(mapfilepath, efifilepath= ):
>
>
>=C2=A0 =C2=A0 =C2=A0 if len(lines) =3D=3D 0: return None
>
>=C2=A0 =C2=A0 =C2=A0 firstline =3D lines[0].strip()
>
> -=C2=A0 =C2=A0 if re.match('^\s*Address\s*Size\s*Align\s*Out\s*In\= s*Symbol\s*$',
> firstline):
>
> +=C2=A0 =C2=A0 if re.match(r'^\s*Address\s*Size\s*Align\s*Out\s*In= \s*Symbol\s*$',
> firstline):
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return _parseForXcodeAndClang9(lines= , efifilepath)
>
>=C2=A0 =C2=A0 =C2=A0 if (firstline.startswith("Archive member incl= uded ") and
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 firstline.endswith(" file (symb= ol)")):
>
> @@ -59,12 +59,12 @@ def parsePcdInfoFromMapFile(mapfilepath,
> efifilepath):
>=C2=A0 =C2=A0 =C2=A0 return _parseGeneral(lines, efifilepath)
>
>
>
>=C2=A0 def _parseForXcodeAndClang9(lines, efifilepath):
>
> -=C2=A0 =C2=A0 valuePattern =3D
> re.compile('^([\da-fA-FxX]+)([\s\S]*)([_]*_gPcd_BinaryPatch_([\w]+= ))')
>
> +=C2=A0 =C2=A0 valuePattern =3D
> re.compile(r'^([\da-fA-FxX]+)([\s\S]*)([_]*_gPcd_BinaryPatch_([\w]= +))')
>
>=C2=A0 =C2=A0 =C2=A0 status =3D 0
>
>=C2=A0 =C2=A0 =C2=A0 pcds =3D []
>
>=C2=A0 =C2=A0 =C2=A0 for line in lines:
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 line =3D line.strip()
>
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 if status =3D=3D 0 and
> (re.match('^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$'= , line) \
>
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 if status =3D=3D 0 and
> (re.match(r'^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$'= ;, line) \
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 or line =3D=3D "#= Symbols:"):
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 status =3D 1
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 continue
>
> @@ -77,7 +77,7 @@ def _parseForXcodeAndClang9(lines, efifilepath):
>
>
>=C2=A0 def _parseForGCC(lines, efifilepath):
>
>=C2=A0 =C2=A0 =C2=A0 """ Parse map file generated by GCC= linker """
>
> -=C2=A0 =C2=A0 dataPattern =3D re.compile('^.data._gPcd_BinaryPatc= h_([\w_\d]+)$')
>
> +=C2=A0 =C2=A0 dataPattern =3D re.compile(r'^.data._gPcd_BinaryPat= ch_([\w_\d]+)$')
>
>=C2=A0 =C2=A0 =C2=A0 status =3D 0
>
>=C2=A0 =C2=A0 =C2=A0 imageBase =3D -1
>
>=C2=A0 =C2=A0 =C2=A0 sections =3D []
>
> @@ -136,7 +136,7 @@ def _parseGeneral(lines, efifilepath):
>=C2=A0 =C2=A0 =C2=A0 status =3D 0=C2=A0 =C2=A0 #0 - beginning of file; = 1 - PE section definition; 2 -
symbol
> table
>
>=C2=A0 =C2=A0 =C2=A0 secs =3D []=C2=A0 =C2=A0 # key =3D section name >
>=C2=A0 =C2=A0 =C2=A0 bPcds =3D []
>
> -=C2=A0 =C2=A0 symPattern =3D re.compile('^[_]+gPcd_BinaryPatch_([= \w]+)')
>
> +=C2=A0 =C2=A0 symPattern =3D re.compile(r'^[_]+gPcd_BinaryPatch_(= [\w]+)')
>
>
>
>=C2=A0 =C2=A0 =C2=A0 for line in lines:
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 line =3D line.strip()
>
> diff --git a/BaseTools/Source/Python/Trim/Trim.py
> b/BaseTools/Source/Python/Trim/Trim.py
> index 416935df5e90..6d7bc0551026 100644
> --- a/BaseTools/Source/Python/Trim/Trim.py
> +++ b/BaseTools/Source/Python/Trim/Trim.py
> @@ -28,15 +28,15 @@ __version__ =3D "%prog Version " +
> __version_number__
>=C2=A0 __copyright__ =3D "Copyright (c) 2007-2018, Intel Corporati= on. All rights
> reserved."
>
>
>
>=C2=A0 ## Regular expression for matching Line Control directive like &= quot;#line
xxx"
>
> -gLineControlDirective =3D
re.compile('^\s*#(?:line)?\s+([0-9]+)\s+"*([^"]*)"')=
>
> +gLineControlDirective =3D
re.compile(r'^\s*#(?:line)?\s+([0-9]+)\s+"*([^"]*)"'= )
>
>=C2=A0 ## Regular expression for matching "typedef struct" >
> -gTypedefPattern =3D re.compile("^\s*typedef\s+struct(\s+\w+)?\s*= [{]*$",
> re.MULTILINE)
>
> +gTypedefPattern =3D re.compile(r"^\s*typedef\s+struct(\s+\w+)?\s= *[{]*$",
> re.MULTILINE)
>
>=C2=A0 ## Regular expression for matching "#pragma pack"
>
> -gPragmaPattern =3D re.compile("^\s*#pragma\s+pack", re.MULT= ILINE)
>
> +gPragmaPattern =3D re.compile(r"^\s*#pragma\s+pack", re.MUL= TILINE)
>
>=C2=A0 ## Regular expression for matching "typedef"
>
> -gTypedef_SinglePattern =3D re.compile("^\s*typedef", re.MUL= TILINE)
>
> +gTypedef_SinglePattern =3D re.compile(r"^\s*typedef", re.MU= LTILINE)
>
>=C2=A0 ## Regular expression for matching "typedef struct, typedef= union,
struct,
> union"
>
> -gTypedef_MulPattern =3D
> re.compile("^\s*(typedef)?\s+(struct|union)(\s+\w+)?\s*[{]*$"= ;,
> re.MULTILINE)
>
> +gTypedef_MulPattern =3D
> re.compile(r"^\s*(typedef)?\s+(struct|union)(\s+\w+)?\s*[{]*$&quo= t;,
> re.MULTILINE)
>
>
>
>=C2=A0 #
>
>=C2=A0 # The following number pattern match will only match if followin= g
criteria is
> met:
>
> @@ -44,14 +44,14 @@ gTypedef_MulPattern =3D
> re.compile("^\s*(typedef)?\s+(struct|union)(\s+\w+)?\s*[{]
>=C2=A0 # as the pattern is greedily match, so it is ok for the gDecNumb= erPattern
or
> gHexNumberPattern to grab the maximum match
>
>=C2=A0 #
>
>=C2=A0 ## Regular expression for matching HEX number
>
> -gHexNumberPattern =3D
>
re.compile("(?<=3D[^a-zA-Z0-9_])(0[xX])([0-9a-fA-F]+)(U(?=3D$|[^a-z= A-Z0-9_]))?")
>
> +gHexNumberPattern =3D
>
re.compile(r"(?<=3D[^a-zA-Z0-9_])(0[xX])([0-9a-fA-F]+)(U(?=3D$|[^a-= zA-Z0-9_]))?"
> )
>
>=C2=A0 ## Regular expression for matching decimal number with 'U= 9; postfix
>
> -gDecNumberPattern =3D
> re.compile("(?<=3D[^a-zA-Z0-9_])([0-9]+)U(?=3D$|[^a-zA-Z0-9_])= ")
>
> +gDecNumberPattern =3D
> re.compile(r"(?<=3D[^a-zA-Z0-9_])([0-9]+)U(?=3D$|[^a-zA-Z0-9_]= )")
>
>=C2=A0 ## Regular expression for matching constant with 'ULL' &= #39;LL' postfix
>
> -gLongNumberPattern =3D
> re.compile("(?<=3D[^a-zA-Z0-9_])(0[xX][0-9a-fA-F]+|[0-9]+)U?LL= (?=3D$|[^a-zA-Z0
> -9_])")
>
> +gLongNumberPattern =3D
> re.compile(r"(?<=3D[^a-zA-Z0-9_])(0[xX][0-9a-fA-F]+|[0-9]+)U?L= L(?=3D$|[^a-zA-Z
> 0-9_])")
>
>
>
>=C2=A0 ## Regular expression for matching "Include ()" in asl= file
>
> -gAslIncludePattern =3D
re.compile("^(\s*)[iI]nclude\s*\(\"?([^\"\(\)]+)\"\)&qu= ot;,
> re.MULTILINE)
>
> +gAslIncludePattern =3D
re.compile(r"^(\s*)[iI]nclude\s*\(\"?([^\"\(\)]+)\"\)&q= uot;,
> re.MULTILINE)
>
>=C2=A0 ## Regular expression for matching C style #include "XXX.as= l" in asl file
>
>=C2=A0 gAslCIncludePattern =3D
> re.compile(r'^(\s*)#include\s*[<"]\s*([-\\/\w.]+)\s*([>= "])', re.MULTILINE)
>
>=C2=A0 ## Patterns used to convert EDK conventions to EDK2 ECP conventi= ons
>
> diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py
> b/BaseTools/Source/Python/Workspace/DscBuildData.py
> index 8fd949dc50b6..817cdbe5f19c 100644
> --- a/BaseTools/Source/Python/Workspace/DscBuildData.py
> +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
> @@ -90,7 +90,7 @@ PcdMakefileHeader =3D '''
>
>
>=C2=A0 WindowsCFLAGS =3D 'CFLAGS =3D $(CFLAGS) /wd4200 /wd4034 /wd4= 101 '
>
>=C2=A0 LinuxCFLAGS =3D 'CFLAGS +=3D -Wno-pointer-to-int-cast -Wno-u= nused-variable '
>
> -PcdMakefileEnd =3D '''
>
> +PcdMakefileEnd =3D r'''
>
>=C2=A0 !INCLUDE $(BASE_TOOLS_PATH)\Source\C\Makefiles\ms.common
>
>=C2=A0 !INCLUDE $(BASE_TOOLS_PATH)\Source\C\Makefiles\ms.app
>
>=C2=A0 '''
>
> @@ -110,7 +110,7 @@ LIBS =3D -lCommon
>=C2=A0 variablePattern =3D re.compile(r'[\t\s]*0[xX][a-fA-F0-9]+$&#= 39;)
>
>=C2=A0 SkuIdPattern =3D re.compile(r'^[a-zA-Z_][a-zA-Z0-9_]*$')=
>
>=C2=A0 ## regular expressions for finding decimal and hex numbers
>
> -Pattern =3D re.compile('^[1-9]\d*|0$')
>
> +Pattern =3D re.compile(r'^[1-9]\d*|0$')
>
>=C2=A0 HexPattern =3D re.compile(r'0[xX][0-9a-fA-F]+$')
>
>=C2=A0 ## Regular expression for finding header file inclusions
>
>=C2=A0 from AutoGen.GenMake import gIncludePattern
>
> @@ -2840,7 +2840,7 @@ class DscBuildData(PlatformBuildClassObject): >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 # start generating makefile
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 MakeApp =3D PcdMakefileHeader
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if sys.platform =3D=3D "win32&q= uot;:
>
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 MakeApp =3D MakeApp + '= APPFILE =3D %s\%s.exe\n' %
> (self.OutputPath, PcdValueInitName) + 'APPNAME =3D %s\n' %
> (PcdValueInitName) + 'OBJECTS =3D %s\%s.obj %s.obj\n' % (self.= OutputPath,
> PcdValueInitName, os.path.join(self.OutputPath, PcdValueCommonName)) +=
> 'INC =3D '
>
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 MakeApp =3D MakeApp + r'= ;APPFILE =3D %s\%s.exe\n' %
> (self.OutputPath, PcdValueInitName) + r'APPNAME =3D %s\n' % > (PcdValueInitName) + r'OBJECTS =3D %s\%s.obj %s.obj\n' % (self= .OutputPath,
> PcdValueInitName, os.path.join(self.OutputPath, PcdValueCommonName)) +=
> 'INC =3D '
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 else:
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 MakeApp =3D MakeApp + = PcdGccMakefile
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 MakeApp =3D MakeApp + = 'APPFILE =3D %s/%s\n' %
> (self.OutputPath, PcdValueInitName) + 'APPNAME =3D %s\n' %
> (PcdValueInitName) + 'OBJECTS =3D %s/%s.o %s.o\n' % (self.Outp= utPath,
> PcdValueInitName, os.path.join(self.OutputPath, PcdValueCommonName)) += \
>
> @@ -2950,7 +2950,7 @@ class DscBuildData(PlatformBuildClassObject): >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 MakeApp +=3D "$(O= BJECTS) : %s\n" % include_file
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if sys.platform =3D=3D "win32&q= uot;:
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 PcdValueCommonPath =3D=
> os.path.normpath(mws.join(GlobalData.gGlobalDefines["EDK_TOOLS_PA= TH"],
> "Source\C\Common\PcdValueCommon.c"))
>
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 MakeApp =3D MakeApp + '= %s\PcdValueCommon.c : %s\n' %
> (self.OutputPath, PcdValueCommonPath)
>
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 MakeApp =3D MakeApp + r'= ;%s\PcdValueCommon.c : %s\n' %
> (self.OutputPath, PcdValueCommonPath)
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 MakeApp =3D MakeApp + = '\tcopy /y %s $@\n' %
> (PcdValueCommonPath)
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 else:
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 PcdValueCommonPath =3D=
> os.path.normpath(mws.join(GlobalData.gGlobalDefines["EDK_TOOLS_PA= TH"],
> "Source/C/Common/PcdValueCommon.c"))
>
> diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py
> b/BaseTools/Source/Python/Workspace/MetaFileParser.py
> index 3508591b281e..73a1654edb30 100644
> --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py
> +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py
> @@ -1897,7 +1897,7 @@ class DecParser(MetaFileParser):
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self._SectionType =3D []
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ArchList =3D set()
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 PrivateList =3D set()
>
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 Line =3D re.sub(',[\s]*', TAB_COM= MA_SPLIT, self._CurrentLine)
>
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 Line =3D re.sub(r',[\s]*', TAB_CO= MMA_SPLIT, self._CurrentLine)
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 for Item in Line[1:-1].split(TAB_COM= MA_SPLIT):
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if Item =3D=3D '&#= 39;:
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 EdkLogge= r.error("Parser", FORMAT_UNKNOWN_ERROR,
>
> --
> 2.43.0.windows.1



_._,_._,_

Groups.io Links:

=20 You receive all messages sent to this group. =20 =20

View/Reply Online (#112491) | =20 | Mute= This Topic | New Topic
Your Subscriptio= n | Contact Group Owner | Unsubscribe [rebecca@openfw.io]

_._,_._,_
--000000000000c7f5f1060c6abbf1--