public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-devel] [PATCH v1 0/1] Resolve regex syntax warnings
@ 2023-12-06 20:27 Joey Vagedes via groups.io
  2023-12-06 20:27 ` [edk2-devel] [PATCH v1 1/1] BaseTools: " Joey Vagedes via groups.io
  2023-12-20 23:51 ` [edk2-devel] [PATCH v1 0/1] " Rebecca Cran
  0 siblings, 2 replies; 6+ messages in thread
From: Joey Vagedes via groups.io @ 2023-12-06 20:27 UTC (permalink / raw)
  To: devel; +Cc: Rebecca Cran, Liming Gao, Bob Feng, Yuwei Chen

Python 3.12 now produces syntax warnings when using an invalid escape
character (\ followed by an unexpected character). This happens
throughout BaseTools due the usage of regular expressions. the re module
in python suggests that when creating regex patterns, to use raw text.
This patch series adds the r prefix to any regex pattern that uses an
invalid escape sequence.

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>

Joey Vagedes (1):
  BaseTools: Resolve regex syntax warnings

 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(-)

-- 
2.43.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112139): https://edk2.groups.io/g/devel/message/112139
Mute This Topic: https://groups.io/mt/103021364/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [edk2-devel] [PATCH v1 1/1] BaseTools: Resolve regex syntax warnings
  2023-12-06 20:27 [edk2-devel] [PATCH v1 0/1] Resolve regex syntax warnings Joey Vagedes via groups.io
@ 2023-12-06 20:27 ` Joey Vagedes via groups.io
  2023-12-12  0:30   ` [edk2-devel] 回复: " gaoliming via groups.io
  2023-12-20 22:57   ` Rebecca Cran
  2023-12-20 23:51 ` [edk2-devel] [PATCH v1 0/1] " Rebecca Cran
  1 sibling, 2 replies; 6+ messages in thread
From: Joey Vagedes via groups.io @ 2023-12-06 20:27 UTC (permalink / raw)
  To: devel; +Cc: Rebecca Cran, Liming Gao, Bob Feng, Yuwei Chen

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 <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>
---
 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__ = """
+__description__ = 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 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:
     _SubSectionList = [_InputFile, _OutputFile, _Command]
 
     _PATH_SEP = "(+)"
-    _FileTypePattern = re.compile("^[_a-zA-Z][_\-0-9a-zA-Z]*$")
+    _FileTypePattern = re.compile(r"^[_a-zA-Z][_\-0-9a-zA-Z]*$")
     _BinaryFileRule = 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 = re.compile("(\(|\)|\{[^{}]+\{?[^{}]+\}?[ ]*\}|\w+)")
+    TokenPattern = 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 = 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 = re.compile("([_A-Z][_A-Z0-9]*)[ \t]*\((.+)\)", re.UNICODE)
+gMacroPattern = re.compile(r"([_A-Z][_A-Z0-9]*)[ \t]*\((.+)\)", re.UNICODE)
 
 gIsFileMap = {}
 
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 = re.compile('IMAGE_TOKEN *\(([A-Z0-9_]+) *\)', re.MULTILINE | re.UNICODE)
+IMAGE_TOKEN = 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 = "0x00010017"
 #
 # Match name = variable
 #
-gEfiVarStoreNamePattern = re.compile("\s*name\s*=\s*(\w+)")
+gEfiVarStoreNamePattern = re.compile(r"\s*name\s*=\s*(\w+)")
 #
 # The format of guid in efivarstore statement likes following and must be correct:
 # guid = {0xA04A27f4, 0xDF00, 0x4D42, {0xB5, 0x52, 0x39, 0x51, 0x13, 0x02, 0x11, 0x3D}}
 #
-gEfiVarStoreGuidPattern = re.compile("\s*guid\s*=\s*({.*?{.*?}\s*})")
+gEfiVarStoreGuidPattern = re.compile(r"\s*guid\s*=\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 = 'not referenced'
 COMMENT_NOT_REFERENCED = ' ' + COMMENT + NOT_REFERENCED
 CHAR_ARRAY_DEFIN = 'unsigned char'
 COMMON_FILE_NAME = 'Strings'
-STRING_TOKEN = re.compile('STRING_TOKEN *\(([A-Z0-9_]+) *\)', re.MULTILINE | re.UNICODE)
+STRING_TOKEN = re.compile(r'STRING_TOKEN *\(([A-Z0-9_]+) *\)', re.MULTILINE | re.UNICODE)
 
 EFI_HII_ARRAY_SIZE_LENGTH = 4
 EFI_HII_PACKAGE_HEADER_LENGTH = 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 = re.compile("(\(|\)|\w+| \S+\.inf)")
+gDepexTokenPattern = re.compile(r"(\(|\)|\w+| \S+\.inf)")
 
 ## Regular expression for match: PCD(xxxx.yyy)
 gPCDAsGuidPattern = 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          = 'Empty expression is not allowed.'
 ERR_IN_OPERAND          = 'Macro after IN operator can only be: $(FAMILY), $(ARCH), $(TOOL_CHAIN_TAG) and $(TARGET).'
 
 __ValidString = re.compile(r'[_a-zA-Z][_0-9a-zA-Z]*$')
-_ReLabel = re.compile('LABEL\((\w+)\)')
-_ReOffset = re.compile('OFFSET_OF\((\w+)\)')
+_ReLabel = re.compile(r'LABEL\((\w+)\)')
+_ReOffset = re.compile(r'OFFSET_OF\((\w+)\)')
 PcdPattern = 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 = re.compile("("
-                                 "\$\([A-Z][A-Z0-9_]*\)|\$\(\w+\.\w+\)|\w+\.\w+|"
-                                 "&&|\|\||!(?!=)|"
-                                 "(?<=\W)AND(?=\W)|(?<=\W)OR(?=\W)|(?<=\W)NOT(?=\W)|(?<=\W)XOR(?=\W)|"
-                                 "(?<=\W)EQ(?=\W)|(?<=\W)NE(?=\W)|(?<=\W)GT(?=\W)|(?<=\W)LT(?=\W)|(?<=\W)GE(?=\W)|(?<=\W)LE(?=\W)"
+                                 r"\$\([A-Z][A-Z0-9_]*\)|\$\(\w+\.\w+\)|\w+\.\w+|"
+                                 r"&&|\|\||!(?!=)|"
+                                 r"(?<=\W)AND(?=\W)|(?<=\W)OR(?=\W)|(?<=\W)NOT(?=\W)|(?<=\W)XOR(?=\W)|"
+                                 r"(?<=\W)EQ(?=\W)|(?<=\W)NE(?=\W)|(?<=\W)GT(?=\W)|(?<=\W)LT(?=\W)|(?<=\W)GE(?=\W)|(?<=\W)LE(?=\W)"
                                ")")
 
     @staticmethod
@@ -737,7 +737,7 @@ class ValueExpression(BaseExpression):
             self._Token = "'" + UStr + "'"
             return self._Token
         elif Expr.startswith('UINT'):
-            Re = re.compile('(?:UINT8|UINT16|UINT32|UINT64)\((.+)\)')
+            Re = re.compile(r'(?:UINT8|UINT16|UINT32|UINT64)\((.+)\)')
             try:
                 RetValue = Re.search(Expr).group(1)
             except:
@@ -975,7 +975,7 @@ class ValueExpressionEx(ValueExpression):
                                 TokenSpaceGuidName = ''
                                 if Item.startswith(TAB_GUID) and Item.endswith(')'):
                                     try:
-                                        TokenSpaceGuidName = re.search('GUID\((\w+)\)', Item).group(1)
+                                        TokenSpaceGuidName = 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 = []
 gGuidDict = {}
 
 # definition for a MACRO name.  used to create regular expressions below.
-_MacroNamePattern = "[A-Z][A-Z0-9_]*"
+_MacroNamePattern = r"[A-Z][A-Z0-9_]*"
 
 ## Regular expression for matching macro used in DSC/DEC/INF file inclusion
-gMacroRefPattern = re.compile("\$\(({})\)".format(_MacroNamePattern), re.UNICODE)
+gMacroRefPattern = re.compile(r"\$\(({})\)".format(_MacroNamePattern), re.UNICODE)
 gMacroDefPattern = re.compile("^(DEFINE|EDK_GLOBAL)[ \t]+")
 gMacroNamePattern = 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 = re.compile("\[\s*[0-9a-fA-FxX]*\s*\]")
+ArrayIndex = re.compile(r"\[\s*[0-9a-fA-FxX]*\s*\]")
 ## Regular expression used to find out place holders in string template
-gPlaceholderPattern = re.compile("\$\{([^$()\s]+)\}", re.MULTILINE | re.UNICODE)
+gPlaceholderPattern = re.compile(r"\$\{([^$()\s]+)\}", re.MULTILINE | re.UNICODE)
 
 ## regular expressions for map file processing
-startPatternGeneral = re.compile("^Start[' ']+Length[' ']+Name[' ']+Class")
-addressPatternGeneral = re.compile("^Address[' ']+Publics by Value[' ']+Rva\+Base")
-valuePatternGcc = re.compile('^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-Fx]+)$')
-pcdPatternGcc = re.compile('^([\da-fA-Fx]+) +([\da-fA-Fx]+)')
-secReGeneral = re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\da-fA-F]+)[Hh]? +([.\w\$]+) +(\w+)', re.UNICODE)
+startPatternGeneral = re.compile(r"^Start[' ']+Length[' ']+Name[' ']+Class")
+addressPatternGeneral = re.compile(r"^Address[' ']+Publics by Value[' ']+Rva\+Base")
+valuePatternGcc = re.compile(r'^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-Fx]+)$')
+pcdPatternGcc = re.compile(r'^([\da-fA-Fx]+) +([\da-fA-Fx]+)')
+secReGeneral = re.compile(r'^([\da-fA-F]+):([\da-fA-F]+) +([\da-fA-F]+)[Hh]? +([.\w\$]+) +(\w+)', re.UNICODE)
 
 StructPattern = re.compile(r'[_a-zA-Z][0-9A-Za-z_]*$')
 
@@ -82,7 +82,7 @@ def GetVariableOffset(mapfilepath, efifilepath, varnames):
 
     if len(lines) == 0: return None
     firstline = 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 = []
     for line in lines:
         line = line.strip()
-        if status == 0 and (re.match('^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', line) \
+        if status == 0 and (re.match(r'^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', line) \
             or line == "# Symbols:"):
             status = 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 = re.match('^([\da-fA-FxX]+)([\s\S]*)([_]*%s)$' % varname, line)
+                    m = 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 = 0    #0 - beginning of file; 1 - PE section definition; 2 - symbol table
     secs  = []    # key = section name
     varoffset = []
-    symRe = re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\.:\\\\\w\?@\$-]+) +([\da-fA-F]+)', re.UNICODE)
+    symRe = re.compile(r'^([\da-fA-F]+):([\da-fA-F]+) +([\.:\\\\\w\?@\$-]+) +([\da-fA-F]+)', re.UNICODE)
 
     for line in lines:
         line = 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=re.S)
+    return re.sub(r'//.*?\n|/\*.*?\*/', '\n', ctext, flags=re.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 = re.compile('(DEF\([^\(\)]+\))')
-gEnvRefPattern = re.compile('(ENV\([^\(\)]+\))')
-gMacroDefPattern = re.compile("DEFINE\s+([^\s]+)")
+gMacroRefPattern = re.compile(r'(DEF\([^\(\)]+\))')
+gEnvRefPattern = re.compile(r'(ENV\([^\(\)]+\))')
+gMacroDefPattern = re.compile(r"DEFINE\s+([^\s]+)")
 gDefaultToolsDefFile = "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 = {"Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K", "6
 ALIGNMENT_NOAUTO = ALIGNMENTS - {"Auto"}
 CR_LB_SET = {T_CHAR_CR, TAB_LINE_BREAK}
 
-RegionSizePattern = compile("\s*(?P<base>(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P<size>(?:0x|0X)?[a-fA-F0-9]+)\s*")
-RegionSizeGuidPattern = compile("\s*(?P<base>\w+\.\w+[\.\w\[\]]*)\s*\|\s*(?P<size>\w+\.\w+[\.\w\[\]]*)\s*")
-RegionOffsetPcdPattern = compile("\s*(?P<base>\w+\.\w+[\.\w\[\]]*)\s*$")
-ShortcutPcdPattern = compile("\s*\w+\s*=\s*(?P<value>(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P<name>\w+\.\w+)\s*")
-BaseAddrValuePattern = compile('^0[xX][0-9a-fA-F]+')
+RegionSizePattern = compile(r"\s*(?P<base>(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P<size>(?:0x|0X)?[a-fA-F0-9]+)\s*")
+RegionSizeGuidPattern = compile(r"\s*(?P<base>\w+\.\w+[\.\w\[\]]*)\s*\|\s*(?P<size>\w+\.\w+[\.\w\[\]]*)\s*")
+RegionOffsetPcdPattern = compile(r"\s*(?P<base>\w+\.\w+[\.\w\[\]]*)\s*$")
+ShortcutPcdPattern = compile(r"\s*\w+\s*=\s*(?P<value>(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P<name>\w+\.\w+)\s*")
+BaseAddrValuePattern = compile(r'^0[xX][0-9a-fA-F]+')
 FileExtensionPattern = compile(r'([a-zA-Z][a-zA-Z0-9]*)')
 TokenFindPattern = compile(r'([a-zA-Z0-9\-]+|\$\(TARGET\)|\*)_([a-zA-Z0-9\-]+|\$\(TOOL_CHAIN_TAG\)|\*)_([a-zA-Z0-9\-]+|\$\(ARCH\)|\*)')
 AllIncludeFileList = []
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 = {}
-                        ReFileEnds = compile('\S+(.ui)$|\S+(fv.sec.txt)$|\S+(.pe32.txt)$|\S+(.te.txt)$|\S+(.pic.txt)$|\S+(.raw.txt)$|\S+(.ffs.txt)$')
+                        ReFileEnds = compile(r'\S+(.ui)$|\S+(fv.sec.txt)$|\S+(.pe32.txt)$|\S+(.te.txt)$|\S+(.pic.txt)$|\S+(.raw.txt)$|\S+(.ffs.txt)$')
                         FileList = os.listdir(FfsPath[0])
                         for File in FileList:
                             Match = 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__ = "Copyright (c) 2008 - 2018, Intel Corporation. All rights reserv
 #======================================  Internal Libraries ========================================
 
 #============================================== Code ===============================================
-symRe = re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\.\-:\\\\\w\?@\$<>]+) +([\da-fA-F]+)', re.UNICODE)
+symRe = 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) == 0: return None
     firstline = 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 = re.compile('^([\da-fA-FxX]+)([\s\S]*)([_]*_gPcd_BinaryPatch_([\w]+))')
+    valuePattern = re.compile(r'^([\da-fA-FxX]+)([\s\S]*)([_]*_gPcd_BinaryPatch_([\w]+))')
     status = 0
     pcds = []
     for line in lines:
         line = line.strip()
-        if status == 0 and (re.match('^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', line) \
+        if status == 0 and (re.match(r'^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', line) \
             or line == "# Symbols:"):
             status = 1
             continue
@@ -77,7 +77,7 @@ def _parseForXcodeAndClang9(lines, efifilepath):
 
 def _parseForGCC(lines, efifilepath):
     """ Parse map file generated by GCC linker """
-    dataPattern = re.compile('^.data._gPcd_BinaryPatch_([\w_\d]+)$')
+    dataPattern = re.compile(r'^.data._gPcd_BinaryPatch_([\w_\d]+)$')
     status = 0
     imageBase = -1
     sections = []
@@ -136,7 +136,7 @@ def _parseGeneral(lines, efifilepath):
     status = 0    #0 - beginning of file; 1 - PE section definition; 2 - symbol table
     secs = []    # key = section name
     bPcds = []
-    symPattern = re.compile('^[_]+gPcd_BinaryPatch_([\w]+)')
+    symPattern = re.compile(r'^[_]+gPcd_BinaryPatch_([\w]+)')
 
     for line in lines:
         line = 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__ = "%prog Version " + __version_number__
 __copyright__ = "Copyright (c) 2007-2018, Intel Corporation. All rights reserved."
 
 ## Regular expression for matching Line Control directive like "#line xxx"
-gLineControlDirective = re.compile('^\s*#(?:line)?\s+([0-9]+)\s+"*([^"]*)"')
+gLineControlDirective = re.compile(r'^\s*#(?:line)?\s+([0-9]+)\s+"*([^"]*)"')
 ## Regular expression for matching "typedef struct"
-gTypedefPattern = re.compile("^\s*typedef\s+struct(\s+\w+)?\s*[{]*$", re.MULTILINE)
+gTypedefPattern = re.compile(r"^\s*typedef\s+struct(\s+\w+)?\s*[{]*$", re.MULTILINE)
 ## Regular expression for matching "#pragma pack"
-gPragmaPattern = re.compile("^\s*#pragma\s+pack", re.MULTILINE)
+gPragmaPattern = re.compile(r"^\s*#pragma\s+pack", re.MULTILINE)
 ## Regular expression for matching "typedef"
-gTypedef_SinglePattern = re.compile("^\s*typedef", re.MULTILINE)
+gTypedef_SinglePattern = re.compile(r"^\s*typedef", re.MULTILINE)
 ## Regular expression for matching "typedef struct, typedef union, struct, union"
-gTypedef_MulPattern = re.compile("^\s*(typedef)?\s+(struct|union)(\s+\w+)?\s*[{]*$", re.MULTILINE)
+gTypedef_MulPattern = 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 = 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 = re.compile("(?<=[^a-zA-Z0-9_])(0[xX])([0-9a-fA-F]+)(U(?=$|[^a-zA-Z0-9_]))?")
+gHexNumberPattern = re.compile(r"(?<=[^a-zA-Z0-9_])(0[xX])([0-9a-fA-F]+)(U(?=$|[^a-zA-Z0-9_]))?")
 ## Regular expression for matching decimal number with 'U' postfix
-gDecNumberPattern = re.compile("(?<=[^a-zA-Z0-9_])([0-9]+)U(?=$|[^a-zA-Z0-9_])")
+gDecNumberPattern = re.compile(r"(?<=[^a-zA-Z0-9_])([0-9]+)U(?=$|[^a-zA-Z0-9_])")
 ## Regular expression for matching constant with 'ULL' 'LL' postfix
-gLongNumberPattern = re.compile("(?<=[^a-zA-Z0-9_])(0[xX][0-9a-fA-F]+|[0-9]+)U?LL(?=$|[^a-zA-Z0-9_])")
+gLongNumberPattern = re.compile(r"(?<=[^a-zA-Z0-9_])(0[xX][0-9a-fA-F]+|[0-9]+)U?LL(?=$|[^a-zA-Z0-9_])")
 
 ## Regular expression for matching "Include ()" in asl file
-gAslIncludePattern = re.compile("^(\s*)[iI]nclude\s*\(\"?([^\"\(\)]+)\"\)", re.MULTILINE)
+gAslIncludePattern = re.compile(r"^(\s*)[iI]nclude\s*\(\"?([^\"\(\)]+)\"\)", re.MULTILINE)
 ## Regular expression for matching C style #include "XXX.asl" in asl file
 gAslCIncludePattern = 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 = '''
 
 WindowsCFLAGS = 'CFLAGS = $(CFLAGS) /wd4200 /wd4034 /wd4101 '
 LinuxCFLAGS = 'CFLAGS += -Wno-pointer-to-int-cast -Wno-unused-variable '
-PcdMakefileEnd = '''
+PcdMakefileEnd = r'''
 !INCLUDE $(BASE_TOOLS_PATH)\Source\C\Makefiles\ms.common
 !INCLUDE $(BASE_TOOLS_PATH)\Source\C\Makefiles\ms.app
 '''
@@ -110,7 +110,7 @@ LIBS = -lCommon
 variablePattern = re.compile(r'[\t\s]*0[xX][a-fA-F0-9]+$')
 SkuIdPattern = re.compile(r'^[a-zA-Z_][a-zA-Z0-9_]*$')
 ## regular expressions for finding decimal and hex numbers
-Pattern = re.compile('^[1-9]\d*|0$')
+Pattern = re.compile(r'^[1-9]\d*|0$')
 HexPattern = 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 = PcdMakefileHeader
         if sys.platform == "win32":
-            MakeApp = MakeApp + 'APPFILE = %s\%s.exe\n' % (self.OutputPath, PcdValueInitName) + 'APPNAME = %s\n' % (PcdValueInitName) + 'OBJECTS = %s\%s.obj %s.obj\n' % (self.OutputPath, PcdValueInitName, os.path.join(self.OutputPath, PcdValueCommonName)) + 'INC = '
+            MakeApp = MakeApp + r'APPFILE = %s\%s.exe\n' % (self.OutputPath, PcdValueInitName) + r'APPNAME = %s\n' % (PcdValueInitName) + r'OBJECTS = %s\%s.obj %s.obj\n' % (self.OutputPath, PcdValueInitName, os.path.join(self.OutputPath, PcdValueCommonName)) + 'INC = '
         else:
             MakeApp = MakeApp + PcdGccMakefile
             MakeApp = MakeApp + 'APPFILE = %s/%s\n' % (self.OutputPath, PcdValueInitName) + 'APPNAME = %s\n' % (PcdValueInitName) + 'OBJECTS = %s/%s.o %s.o\n' % (self.OutputPath, PcdValueInitName, os.path.join(self.OutputPath, PcdValueCommonName)) + \
@@ -2950,7 +2950,7 @@ class DscBuildData(PlatformBuildClassObject):
             MakeApp += "$(OBJECTS) : %s\n" % include_file
         if sys.platform == "win32":
             PcdValueCommonPath = os.path.normpath(mws.join(GlobalData.gGlobalDefines["EDK_TOOLS_PATH"], "Source\C\Common\PcdValueCommon.c"))
-            MakeApp = MakeApp + '%s\PcdValueCommon.c : %s\n' % (self.OutputPath, PcdValueCommonPath)
+            MakeApp = MakeApp + r'%s\PcdValueCommon.c : %s\n' % (self.OutputPath, PcdValueCommonPath)
             MakeApp = MakeApp + '\tcopy /y %s $@\n' % (PcdValueCommonPath)
         else:
             PcdValueCommonPath = 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 = []
         ArchList = set()
         PrivateList = set()
-        Line = re.sub(',[\s]*', TAB_COMMA_SPLIT, self._CurrentLine)
+        Line = re.sub(r',[\s]*', TAB_COMMA_SPLIT, self._CurrentLine)
         for Item in Line[1:-1].split(TAB_COMMA_SPLIT):
             if Item == '':
                 EdkLogger.error("Parser", FORMAT_UNKNOWN_ERROR,
-- 
2.43.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112140): https://edk2.groups.io/g/devel/message/112140
Mute This Topic: https://groups.io/mt/103021365/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [edk2-devel] 回复: [PATCH v1 1/1] BaseTools: Resolve regex syntax warnings
  2023-12-06 20:27 ` [edk2-devel] [PATCH v1 1/1] BaseTools: " Joey Vagedes via groups.io
@ 2023-12-12  0:30   ` gaoliming via groups.io
  2023-12-13 21:20     ` [edk2-devel] " Joey Vagedes via groups.io
  2023-12-20 22:57   ` Rebecca Cran
  1 sibling, 1 reply; 6+ messages in thread
From: gaoliming via groups.io @ 2023-12-12  0:30 UTC (permalink / raw)
  To: 'Joey Vagedes', devel
  Cc: 'Rebecca Cran', 'Bob Feng', 'Yuwei Chen'

Joey:
  Does this change still work on old python version, such as Python 3.9? 

Thanks
Liming
> -----邮件原件-----
> 发件人: Joey Vagedes <joey.vagedes@gmail.com>
> 发送时间: 2023年12月7日 4:27
> 收件人: devel@edk2.groups.io
> 抄送: Rebecca Cran <rebecca@bsdio.com>; Liming Gao
> <gaoliming@byosoft.com.cn>; Bob Feng <bob.c.feng@intel.com>; Yuwei Chen
> <yuwei.chen@intel.com>
> 主题: [PATCH v1 1/1] BaseTools: Resolve regex syntax warnings
> 
> 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 <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>
> ---
>  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__ = """
> 
> +__description__ = 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 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:
>      _SubSectionList = [_InputFile, _OutputFile, _Command]
> 
> 
> 
>      _PATH_SEP = "(+)"
> 
> -    _FileTypePattern = re.compile("^[_a-zA-Z][_\-0-9a-zA-Z]*$")
> 
> +    _FileTypePattern = re.compile(r"^[_a-zA-Z][_\-0-9a-zA-Z]*$")
> 
>      _BinaryFileRule = 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 = re.compile("(\(|\)|\{[^{}]+\{?[^{}]+\}?[ ]*\}|\w+)")
> 
> +    TokenPattern = 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 =
> 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 = re.compile("([_A-Z][_A-Z0-9]*)[ \t]*\((.+)\)",
re.UNICODE)
> 
> +gMacroPattern = re.compile(r"([_A-Z][_A-Z0-9]*)[ \t]*\((.+)\)",
re.UNICODE)
> 
> 
> 
>  gIsFileMap = {}
> 
> 
> 
> 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 = re.compile('IMAGE_TOKEN *\(([A-Z0-9_]+) *\)',
> re.MULTILINE | re.UNICODE)
> 
> +IMAGE_TOKEN = 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 = "0x00010017"
>  #
> 
>  # Match name = variable
> 
>  #
> 
> -gEfiVarStoreNamePattern = re.compile("\s*name\s*=\s*(\w+)")
> 
> +gEfiVarStoreNamePattern = re.compile(r"\s*name\s*=\s*(\w+)")
> 
>  #
> 
>  # The format of guid in efivarstore statement likes following and must be
> correct:
> 
>  # guid = {0xA04A27f4, 0xDF00, 0x4D42, {0xB5, 0x52, 0x39, 0x51, 0x13,
0x02,
> 0x11, 0x3D}}
> 
>  #
> 
> -gEfiVarStoreGuidPattern = re.compile("\s*guid\s*=\s*({.*?{.*?}\s*})")
> 
> +gEfiVarStoreGuidPattern = re.compile(r"\s*guid\s*=\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 = 'not referenced'
>  COMMENT_NOT_REFERENCED = ' ' + COMMENT + NOT_REFERENCED
> 
>  CHAR_ARRAY_DEFIN = 'unsigned char'
> 
>  COMMON_FILE_NAME = 'Strings'
> 
> -STRING_TOKEN = re.compile('STRING_TOKEN *\(([A-Z0-9_]+) *\)',
> re.MULTILINE | re.UNICODE)
> 
> +STRING_TOKEN = re.compile(r'STRING_TOKEN *\(([A-Z0-9_]+) *\)',
> re.MULTILINE | re.UNICODE)
> 
> 
> 
>  EFI_HII_ARRAY_SIZE_LENGTH = 4
> 
>  EFI_HII_PACKAGE_HEADER_LENGTH = 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 = re.compile("(\(|\)|\w+| \S+\.inf)")
> 
> +gDepexTokenPattern = re.compile(r"(\(|\)|\w+| \S+\.inf)")
> 
> 
> 
>  ## Regular expression for match: PCD(xxxx.yyy)
> 
>  gPCDAsGuidPattern = 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          = 'Empty expression is
> not allowed.'
>  ERR_IN_OPERAND          = 'Macro after IN operator can only be:
> $(FAMILY), $(ARCH), $(TOOL_CHAIN_TAG) and $(TARGET).'
> 
> 
> 
>  __ValidString = re.compile(r'[_a-zA-Z][_0-9a-zA-Z]*$')
> 
> -_ReLabel = re.compile('LABEL\((\w+)\)')
> 
> -_ReOffset = re.compile('OFFSET_OF\((\w+)\)')
> 
> +_ReLabel = re.compile(r'LABEL\((\w+)\)')
> 
> +_ReOffset = re.compile(r'OFFSET_OF\((\w+)\)')
> 
>  PcdPattern =
> 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 = re.compile("("
> 
> -
> "\$\([A-Z][A-Z0-9_]*\)|\$\(\w+\.\w+\)|\w+\.\w+|"
> 
> -                                 "&&|\|\||!(?!=)|"
> 
> -
> "(?<=\W)AND(?=\W)|(?<=\W)OR(?=\W)|(?<=\W)NOT(?=\W)|(?<=\W)XOR(?=
> \W)|"
> 
> -
> "(?<=\W)EQ(?=\W)|(?<=\W)NE(?=\W)|(?<=\W)GT(?=\W)|(?<=\W)LT(?=\W)|(
> ?<=\W)GE(?=\W)|(?<=\W)LE(?=\W)"
> 
> +
> r"\$\([A-Z][A-Z0-9_]*\)|\$\(\w+\.\w+\)|\w+\.\w+|"
> 
> +                                 r"&&|\|\||!(?!=)|"
> 
> +
> r"(?<=\W)AND(?=\W)|(?<=\W)OR(?=\W)|(?<=\W)NOT(?=\W)|(?<=\W)XOR(?
> =\W)|"
> 
> +
> r"(?<=\W)EQ(?=\W)|(?<=\W)NE(?=\W)|(?<=\W)GT(?=\W)|(?<=\W)LT(?=\W)|
> (?<=\W)GE(?=\W)|(?<=\W)LE(?=\W)"
> 
>                                 ")")
> 
> 
> 
>      @staticmethod
> 
> @@ -737,7 +737,7 @@ class ValueExpression(BaseExpression):
>              self._Token = "'" + UStr + "'"
> 
>              return self._Token
> 
>          elif Expr.startswith('UINT'):
> 
> -            Re = re.compile('(?:UINT8|UINT16|UINT32|UINT64)\((.+)\)')
> 
> +            Re =
> re.compile(r'(?:UINT8|UINT16|UINT32|UINT64)\((.+)\)')
> 
>              try:
> 
>                  RetValue = Re.search(Expr).group(1)
> 
>              except:
> 
> @@ -975,7 +975,7 @@ class ValueExpressionEx(ValueExpression):
>                                  TokenSpaceGuidName = ''
> 
>                                  if Item.startswith(TAB_GUID) and
> Item.endswith(')'):
> 
>                                      try:
> 
> -                                        TokenSpaceGuidName =
> re.search('GUID\((\w+)\)', Item).group(1)
> 
> +                                        TokenSpaceGuidName =
> 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 = []
>  gGuidDict = {}
> 
> 
> 
>  # definition for a MACRO name.  used to create regular expressions below.
> 
> -_MacroNamePattern = "[A-Z][A-Z0-9_]*"
> 
> +_MacroNamePattern = r"[A-Z][A-Z0-9_]*"
> 
> 
> 
>  ## Regular expression for matching macro used in DSC/DEC/INF file
inclusion
> 
> -gMacroRefPattern = re.compile("\$\(({})\)".format(_MacroNamePattern),
> re.UNICODE)
> 
> +gMacroRefPattern = re.compile(r"\$\(({})\)".format(_MacroNamePattern),
> re.UNICODE)
> 
>  gMacroDefPattern = re.compile("^(DEFINE|EDK_GLOBAL)[ \t]+")
> 
>  gMacroNamePattern = 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 = re.compile("\[\s*[0-9a-fA-FxX]*\s*\]")
> 
> +ArrayIndex = re.compile(r"\[\s*[0-9a-fA-FxX]*\s*\]")
> 
>  ## Regular expression used to find out place holders in string template
> 
> -gPlaceholderPattern = re.compile("\$\{([^$()\s]+)\}", re.MULTILINE |
> re.UNICODE)
> 
> +gPlaceholderPattern = re.compile(r"\$\{([^$()\s]+)\}", re.MULTILINE |
> re.UNICODE)
> 
> 
> 
>  ## regular expressions for map file processing
> 
> -startPatternGeneral = re.compile("^Start[' ']+Length[' ']+Name['
']+Class")
> 
> -addressPatternGeneral = re.compile("^Address[' ']+Publics by Value['
> ']+Rva\+Base")
> 
> -valuePatternGcc = re.compile('^([\w_\.]+) +([\da-fA-Fx]+)
+([\da-fA-Fx]+)$')
> 
> -pcdPatternGcc = re.compile('^([\da-fA-Fx]+) +([\da-fA-Fx]+)')
> 
> -secReGeneral = re.compile('^([\da-fA-F]+):([\da-fA-F]+)
+([\da-fA-F]+)[Hh]?
> +([.\w\$]+) +(\w+)', re.UNICODE)
> 
> +startPatternGeneral = re.compile(r"^Start[' ']+Length[' ']+Name['
']+Class")
> 
> +addressPatternGeneral = re.compile(r"^Address[' ']+Publics by Value['
> ']+Rva\+Base")
> 
> +valuePatternGcc = re.compile(r'^([\w_\.]+) +([\da-fA-Fx]+)
+([\da-fA-Fx]+)$')
> 
> +pcdPatternGcc = re.compile(r'^([\da-fA-Fx]+) +([\da-fA-Fx]+)')
> 
> +secReGeneral = re.compile(r'^([\da-fA-F]+):([\da-fA-F]+)
+([\da-fA-F]+)[Hh]?
> +([.\w\$]+) +(\w+)', re.UNICODE)
> 
> 
> 
>  StructPattern = re.compile(r'[_a-zA-Z][0-9A-Za-z_]*$')
> 
> 
> 
> @@ -82,7 +82,7 @@ def GetVariableOffset(mapfilepath, efifilepath,
> varnames):
> 
> 
>      if len(lines) == 0: return None
> 
>      firstline = 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 = []
> 
>      for line in lines:
> 
>          line = line.strip()
> 
> -        if status == 0 and
> (re.match('^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', line) \
> 
> +        if status == 0 and
> (re.match(r'^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', line) \
> 
>              or line == "# Symbols:"):
> 
>              status = 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 = re.match('^([\da-fA-FxX]+)([\s\S]*)([_]*%s)$' %
> varname, line)
> 
> +                    m = 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 = 0    #0 - beginning of file; 1 - PE section definition; 2 -
symbol
> table
> 
>      secs  = []    # key = section name
> 
>      varoffset = []
> 
> -    symRe = re.compile('^([\da-fA-F]+):([\da-fA-F]+)
+([\.:\\\\\w\?@\$-]+)
> +([\da-fA-F]+)', re.UNICODE)
> 
> +    symRe = re.compile(r'^([\da-fA-F]+):([\da-fA-F]+)
+([\.:\\\\\w\?@\$-]+)
> +([\da-fA-F]+)', re.UNICODE)
> 
> 
> 
>      for line in lines:
> 
>          line = 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=re.S)
> 
> +    return re.sub(r'//.*?\n|/\*.*?\*/', '\n', ctext, flags=re.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 = re.compile('(DEF\([^\(\)]+\))')
> 
> -gEnvRefPattern = re.compile('(ENV\([^\(\)]+\))')
> 
> -gMacroDefPattern = re.compile("DEFINE\s+([^\s]+)")
> 
> +gMacroRefPattern = re.compile(r'(DEF\([^\(\)]+\))')
> 
> +gEnvRefPattern = re.compile(r'(ENV\([^\(\)]+\))')
> 
> +gMacroDefPattern = re.compile(r"DEFINE\s+([^\s]+)")
> 
>  gDefaultToolsDefFile = "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 = {"Auto", "8", "16", "32", "64", "128",
> "512", "1K", "4K", "32K", "6
>  ALIGNMENT_NOAUTO = ALIGNMENTS - {"Auto"}
> 
>  CR_LB_SET = {T_CHAR_CR, TAB_LINE_BREAK}
> 
> 
> 
> -RegionSizePattern =
>
compile("\s*(?P<base>(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P<size>(?:0x|0X)?[a-f
> A-F0-9]+)\s*")
> 
> -RegionSizeGuidPattern =
> compile("\s*(?P<base>\w+\.\w+[\.\w\[\]]*)\s*\|\s*(?P<size>\w+\.\w+[\.\w
> \[\]]*)\s*")
> 
> -RegionOffsetPcdPattern = compile("\s*(?P<base>\w+\.\w+[\.\w\[\]]*)\s*$")
> 
> -ShortcutPcdPattern =
> compile("\s*\w+\s*=\s*(?P<value>(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P<name
> >\w+\.\w+)\s*")
> 
> -BaseAddrValuePattern = compile('^0[xX][0-9a-fA-F]+')
> 
> +RegionSizePattern =
> compile(r"\s*(?P<base>(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P<size>(?:0x|0X)?[a
> -fA-F0-9]+)\s*")
> 
> +RegionSizeGuidPattern =
> compile(r"\s*(?P<base>\w+\.\w+[\.\w\[\]]*)\s*\|\s*(?P<size>\w+\.\w+[\.\w
> \[\]]*)\s*")
> 
> +RegionOffsetPcdPattern =
> compile(r"\s*(?P<base>\w+\.\w+[\.\w\[\]]*)\s*$")
> 
> +ShortcutPcdPattern =
> compile(r"\s*\w+\s*=\s*(?P<value>(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P<name
> >\w+\.\w+)\s*")
> 
> +BaseAddrValuePattern = compile(r'^0[xX][0-9a-fA-F]+')
> 
>  FileExtensionPattern = compile(r'([a-zA-Z][a-zA-Z0-9]*)')
> 
>  TokenFindPattern =
> compile(r'([a-zA-Z0-9\-]+|\$\(TARGET\)|\*)_([a-zA-Z0-9\-]+|\$\(TOOL_CHAI
> N_TAG\)|\*)_([a-zA-Z0-9\-]+|\$\(ARCH\)|\*)')
> 
>  AllIncludeFileList = []
> 
> 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 = {}
> 
> -                        ReFileEnds =
>
compile('\S+(.ui)$|\S+(fv.sec.txt)$|\S+(.pe32.txt)$|\S+(.te.txt)$|\S+(.pic.t
xt)$
> |\S+(.raw.txt)$|\S+(.ffs.txt)$')
> 
> +                        ReFileEnds =
>
compile(r'\S+(.ui)$|\S+(fv.sec.txt)$|\S+(.pe32.txt)$|\S+(.te.txt)$|\S+(.pic.
txt)$
> |\S+(.raw.txt)$|\S+(.ffs.txt)$')
> 
>                          FileList = os.listdir(FfsPath[0])
> 
>                          for File in FileList:
> 
>                              Match = 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__ = "Copyright (c) 2008 - 2018, Intel
> Corporation. All rights reserv
>  #======================================  Internal Libraries
> ========================================
> 
> 
> 
>  #============================================== Code
> ===============================================
> 
> -symRe = re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\.\-:\\\\\w\?@\$<>]+)
> +([\da-fA-F]+)', re.UNICODE)
> 
> +symRe = 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) == 0: return None
> 
>      firstline = 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 =
> re.compile('^([\da-fA-FxX]+)([\s\S]*)([_]*_gPcd_BinaryPatch_([\w]+))')
> 
> +    valuePattern =
> re.compile(r'^([\da-fA-FxX]+)([\s\S]*)([_]*_gPcd_BinaryPatch_([\w]+))')
> 
>      status = 0
> 
>      pcds = []
> 
>      for line in lines:
> 
>          line = line.strip()
> 
> -        if status == 0 and
> (re.match('^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', line) \
> 
> +        if status == 0 and
> (re.match(r'^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', line) \
> 
>              or line == "# Symbols:"):
> 
>              status = 1
> 
>              continue
> 
> @@ -77,7 +77,7 @@ def _parseForXcodeAndClang9(lines, efifilepath):
> 
> 
>  def _parseForGCC(lines, efifilepath):
> 
>      """ Parse map file generated by GCC linker """
> 
> -    dataPattern = re.compile('^.data._gPcd_BinaryPatch_([\w_\d]+)$')
> 
> +    dataPattern = re.compile(r'^.data._gPcd_BinaryPatch_([\w_\d]+)$')
> 
>      status = 0
> 
>      imageBase = -1
> 
>      sections = []
> 
> @@ -136,7 +136,7 @@ def _parseGeneral(lines, efifilepath):
>      status = 0    #0 - beginning of file; 1 - PE section definition; 2 -
symbol
> table
> 
>      secs = []    # key = section name
> 
>      bPcds = []
> 
> -    symPattern = re.compile('^[_]+gPcd_BinaryPatch_([\w]+)')
> 
> +    symPattern = re.compile(r'^[_]+gPcd_BinaryPatch_([\w]+)')
> 
> 
> 
>      for line in lines:
> 
>          line = 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__ = "%prog Version " +
> __version_number__
>  __copyright__ = "Copyright (c) 2007-2018, Intel Corporation. All rights
> reserved."
> 
> 
> 
>  ## Regular expression for matching Line Control directive like "#line
xxx"
> 
> -gLineControlDirective =
re.compile('^\s*#(?:line)?\s+([0-9]+)\s+"*([^"]*)"')
> 
> +gLineControlDirective =
re.compile(r'^\s*#(?:line)?\s+([0-9]+)\s+"*([^"]*)"')
> 
>  ## Regular expression for matching "typedef struct"
> 
> -gTypedefPattern = re.compile("^\s*typedef\s+struct(\s+\w+)?\s*[{]*$",
> re.MULTILINE)
> 
> +gTypedefPattern = re.compile(r"^\s*typedef\s+struct(\s+\w+)?\s*[{]*$",
> re.MULTILINE)
> 
>  ## Regular expression for matching "#pragma pack"
> 
> -gPragmaPattern = re.compile("^\s*#pragma\s+pack", re.MULTILINE)
> 
> +gPragmaPattern = re.compile(r"^\s*#pragma\s+pack", re.MULTILINE)
> 
>  ## Regular expression for matching "typedef"
> 
> -gTypedef_SinglePattern = re.compile("^\s*typedef", re.MULTILINE)
> 
> +gTypedef_SinglePattern = re.compile(r"^\s*typedef", re.MULTILINE)
> 
>  ## Regular expression for matching "typedef struct, typedef union,
struct,
> union"
> 
> -gTypedef_MulPattern =
> re.compile("^\s*(typedef)?\s+(struct|union)(\s+\w+)?\s*[{]*$",
> re.MULTILINE)
> 
> +gTypedef_MulPattern =
> 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 =
> 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 =
>
re.compile("(?<=[^a-zA-Z0-9_])(0[xX])([0-9a-fA-F]+)(U(?=$|[^a-zA-Z0-9_]))?")
> 
> +gHexNumberPattern =
>
re.compile(r"(?<=[^a-zA-Z0-9_])(0[xX])([0-9a-fA-F]+)(U(?=$|[^a-zA-Z0-9_]))?"
> )
> 
>  ## Regular expression for matching decimal number with 'U' postfix
> 
> -gDecNumberPattern =
> re.compile("(?<=[^a-zA-Z0-9_])([0-9]+)U(?=$|[^a-zA-Z0-9_])")
> 
> +gDecNumberPattern =
> re.compile(r"(?<=[^a-zA-Z0-9_])([0-9]+)U(?=$|[^a-zA-Z0-9_])")
> 
>  ## Regular expression for matching constant with 'ULL' 'LL' postfix
> 
> -gLongNumberPattern =
> re.compile("(?<=[^a-zA-Z0-9_])(0[xX][0-9a-fA-F]+|[0-9]+)U?LL(?=$|[^a-zA-Z0
> -9_])")
> 
> +gLongNumberPattern =
> re.compile(r"(?<=[^a-zA-Z0-9_])(0[xX][0-9a-fA-F]+|[0-9]+)U?LL(?=$|[^a-zA-Z
> 0-9_])")
> 
> 
> 
>  ## Regular expression for matching "Include ()" in asl file
> 
> -gAslIncludePattern =
re.compile("^(\s*)[iI]nclude\s*\(\"?([^\"\(\)]+)\"\)",
> re.MULTILINE)
> 
> +gAslIncludePattern =
re.compile(r"^(\s*)[iI]nclude\s*\(\"?([^\"\(\)]+)\"\)",
> re.MULTILINE)
> 
>  ## Regular expression for matching C style #include "XXX.asl" in asl file
> 
>  gAslCIncludePattern =
> 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 = '''
> 
> 
>  WindowsCFLAGS = 'CFLAGS = $(CFLAGS) /wd4200 /wd4034 /wd4101 '
> 
>  LinuxCFLAGS = 'CFLAGS += -Wno-pointer-to-int-cast -Wno-unused-variable '
> 
> -PcdMakefileEnd = '''
> 
> +PcdMakefileEnd = r'''
> 
>  !INCLUDE $(BASE_TOOLS_PATH)\Source\C\Makefiles\ms.common
> 
>  !INCLUDE $(BASE_TOOLS_PATH)\Source\C\Makefiles\ms.app
> 
>  '''
> 
> @@ -110,7 +110,7 @@ LIBS = -lCommon
>  variablePattern = re.compile(r'[\t\s]*0[xX][a-fA-F0-9]+$')
> 
>  SkuIdPattern = re.compile(r'^[a-zA-Z_][a-zA-Z0-9_]*$')
> 
>  ## regular expressions for finding decimal and hex numbers
> 
> -Pattern = re.compile('^[1-9]\d*|0$')
> 
> +Pattern = re.compile(r'^[1-9]\d*|0$')
> 
>  HexPattern = 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 = PcdMakefileHeader
> 
>          if sys.platform == "win32":
> 
> -            MakeApp = MakeApp + 'APPFILE = %s\%s.exe\n' %
> (self.OutputPath, PcdValueInitName) + 'APPNAME = %s\n' %
> (PcdValueInitName) + 'OBJECTS = %s\%s.obj %s.obj\n' % (self.OutputPath,
> PcdValueInitName, os.path.join(self.OutputPath, PcdValueCommonName)) +
> 'INC = '
> 
> +            MakeApp = MakeApp + r'APPFILE = %s\%s.exe\n' %
> (self.OutputPath, PcdValueInitName) + r'APPNAME = %s\n' %
> (PcdValueInitName) + r'OBJECTS = %s\%s.obj %s.obj\n' % (self.OutputPath,
> PcdValueInitName, os.path.join(self.OutputPath, PcdValueCommonName)) +
> 'INC = '
> 
>          else:
> 
>              MakeApp = MakeApp + PcdGccMakefile
> 
>              MakeApp = MakeApp + 'APPFILE = %s/%s\n' %
> (self.OutputPath, PcdValueInitName) + 'APPNAME = %s\n' %
> (PcdValueInitName) + 'OBJECTS = %s/%s.o %s.o\n' % (self.OutputPath,
> PcdValueInitName, os.path.join(self.OutputPath, PcdValueCommonName)) + \
> 
> @@ -2950,7 +2950,7 @@ class DscBuildData(PlatformBuildClassObject):
>              MakeApp += "$(OBJECTS) : %s\n" % include_file
> 
>          if sys.platform == "win32":
> 
>              PcdValueCommonPath =
> os.path.normpath(mws.join(GlobalData.gGlobalDefines["EDK_TOOLS_PATH"],
> "Source\C\Common\PcdValueCommon.c"))
> 
> -            MakeApp = MakeApp + '%s\PcdValueCommon.c : %s\n' %
> (self.OutputPath, PcdValueCommonPath)
> 
> +            MakeApp = MakeApp + r'%s\PcdValueCommon.c : %s\n' %
> (self.OutputPath, PcdValueCommonPath)
> 
>              MakeApp = MakeApp + '\tcopy /y %s $@\n' %
> (PcdValueCommonPath)
> 
>          else:
> 
>              PcdValueCommonPath =
> 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 = []
> 
>          ArchList = set()
> 
>          PrivateList = set()
> 
> -        Line = re.sub(',[\s]*', TAB_COMMA_SPLIT, self._CurrentLine)
> 
> +        Line = re.sub(r',[\s]*', TAB_COMMA_SPLIT, self._CurrentLine)
> 
>          for Item in Line[1:-1].split(TAB_COMMA_SPLIT):
> 
>              if Item == '':
> 
>                  EdkLogger.error("Parser", FORMAT_UNKNOWN_ERROR,
> 
> --
> 2.43.0.windows.1





-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112346): https://edk2.groups.io/g/devel/message/112346
Mute This Topic: https://groups.io/mt/103121314/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [edk2-devel] [PATCH v1 1/1] BaseTools: Resolve regex syntax warnings
  2023-12-12  0:30   ` [edk2-devel] 回复: " gaoliming via groups.io
@ 2023-12-13 21:20     ` Joey Vagedes via groups.io
  0 siblings, 0 replies; 6+ messages in thread
From: Joey Vagedes via groups.io @ 2023-12-13 21:20 UTC (permalink / raw)
  To: gaoliming; +Cc: devel, Rebecca Cran, Bob Feng, Yuwei Chen

[-- Attachment #1: Type: text/plain, Size: 33478 bytes --]

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 PM gaoliming <gaoliming@byosoft.com.cn> wrote:

> Joey:
>   Does this change still work on old python version, such as Python 3.9?
>
> Thanks
> Liming
> > -----邮件原件-----
> > 发件人: Joey Vagedes <joey.vagedes@gmail.com>
> > 发送时间: 2023年12月7日 4:27
> > 收件人: devel@edk2.groups.io
> > 抄送: Rebecca Cran <rebecca@bsdio.com>; Liming Gao
> > <gaoliming@byosoft.com.cn>; Bob Feng <bob.c.feng@intel.com>; Yuwei Chen
> > <yuwei.chen@intel.com>
> > 主题: [PATCH v1 1/1] BaseTools: Resolve regex syntax warnings
> >
> > 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 <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>
> > ---
> >  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__ = """
> >
> > +__description__ = 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 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:
> >      _SubSectionList = [_InputFile, _OutputFile, _Command]
> >
> >
> >
> >      _PATH_SEP = "(+)"
> >
> > -    _FileTypePattern = re.compile("^[_a-zA-Z][_\-0-9a-zA-Z]*$")
> >
> > +    _FileTypePattern = re.compile(r"^[_a-zA-Z][_\-0-9a-zA-Z]*$")
> >
> >      _BinaryFileRule = 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 = re.compile("(\(|\)|\{[^{}]+\{?[^{}]+\}?[ ]*\}|\w+)")
> >
> > +    TokenPattern = 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 =
> > 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 = re.compile("([_A-Z][_A-Z0-9]*)[ \t]*\((.+)\)",
> re.UNICODE)
> >
> > +gMacroPattern = re.compile(r"([_A-Z][_A-Z0-9]*)[ \t]*\((.+)\)",
> re.UNICODE)
> >
> >
> >
> >  gIsFileMap = {}
> >
> >
> >
> > 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 = re.compile('IMAGE_TOKEN *\(([A-Z0-9_]+) *\)',
> > re.MULTILINE | re.UNICODE)
> >
> > +IMAGE_TOKEN = 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 = "0x00010017"
> >  #
> >
> >  # Match name = variable
> >
> >  #
> >
> > -gEfiVarStoreNamePattern = re.compile("\s*name\s*=\s*(\w+)")
> >
> > +gEfiVarStoreNamePattern = re.compile(r"\s*name\s*=\s*(\w+)")
> >
> >  #
> >
> >  # The format of guid in efivarstore statement likes following and must
> be
> > correct:
> >
> >  # guid = {0xA04A27f4, 0xDF00, 0x4D42, {0xB5, 0x52, 0x39, 0x51, 0x13,
> 0x02,
> > 0x11, 0x3D}}
> >
> >  #
> >
> > -gEfiVarStoreGuidPattern = re.compile("\s*guid\s*=\s*({.*?{.*?}\s*})")
> >
> > +gEfiVarStoreGuidPattern = re.compile(r"\s*guid\s*=\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 = 'not referenced'
> >  COMMENT_NOT_REFERENCED = ' ' + COMMENT + NOT_REFERENCED
> >
> >  CHAR_ARRAY_DEFIN = 'unsigned char'
> >
> >  COMMON_FILE_NAME = 'Strings'
> >
> > -STRING_TOKEN = re.compile('STRING_TOKEN *\(([A-Z0-9_]+) *\)',
> > re.MULTILINE | re.UNICODE)
> >
> > +STRING_TOKEN = re.compile(r'STRING_TOKEN *\(([A-Z0-9_]+) *\)',
> > re.MULTILINE | re.UNICODE)
> >
> >
> >
> >  EFI_HII_ARRAY_SIZE_LENGTH = 4
> >
> >  EFI_HII_PACKAGE_HEADER_LENGTH = 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 = re.compile("(\(|\)|\w+| \S+\.inf)")
> >
> > +gDepexTokenPattern = re.compile(r"(\(|\)|\w+| \S+\.inf)")
> >
> >
> >
> >  ## Regular expression for match: PCD(xxxx.yyy)
> >
> >  gPCDAsGuidPattern = 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          = 'Empty expression is
> > not allowed.'
> >  ERR_IN_OPERAND          = 'Macro after IN operator can only be:
> > $(FAMILY), $(ARCH), $(TOOL_CHAIN_TAG) and $(TARGET).'
> >
> >
> >
> >  __ValidString = re.compile(r'[_a-zA-Z][_0-9a-zA-Z]*$')
> >
> > -_ReLabel = re.compile('LABEL\((\w+)\)')
> >
> > -_ReOffset = re.compile('OFFSET_OF\((\w+)\)')
> >
> > +_ReLabel = re.compile(r'LABEL\((\w+)\)')
> >
> > +_ReOffset = re.compile(r'OFFSET_OF\((\w+)\)')
> >
> >  PcdPattern =
> > 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 = re.compile("("
> >
> > -
> > "\$\([A-Z][A-Z0-9_]*\)|\$\(\w+\.\w+\)|\w+\.\w+|"
> >
> > -                                 "&&|\|\||!(?!=)|"
> >
> > -
> > "(?<=\W)AND(?=\W)|(?<=\W)OR(?=\W)|(?<=\W)NOT(?=\W)|(?<=\W)XOR(?=
> > \W)|"
> >
> > -
> > "(?<=\W)EQ(?=\W)|(?<=\W)NE(?=\W)|(?<=\W)GT(?=\W)|(?<=\W)LT(?=\W)|(
> > ?<=\W)GE(?=\W)|(?<=\W)LE(?=\W)"
> >
> > +
> > r"\$\([A-Z][A-Z0-9_]*\)|\$\(\w+\.\w+\)|\w+\.\w+|"
> >
> > +                                 r"&&|\|\||!(?!=)|"
> >
> > +
> > r"(?<=\W)AND(?=\W)|(?<=\W)OR(?=\W)|(?<=\W)NOT(?=\W)|(?<=\W)XOR(?
> > =\W)|"
> >
> > +
> > r"(?<=\W)EQ(?=\W)|(?<=\W)NE(?=\W)|(?<=\W)GT(?=\W)|(?<=\W)LT(?=\W)|
> > (?<=\W)GE(?=\W)|(?<=\W)LE(?=\W)"
> >
> >                                 ")")
> >
> >
> >
> >      @staticmethod
> >
> > @@ -737,7 +737,7 @@ class ValueExpression(BaseExpression):
> >              self._Token = "'" + UStr + "'"
> >
> >              return self._Token
> >
> >          elif Expr.startswith('UINT'):
> >
> > -            Re = re.compile('(?:UINT8|UINT16|UINT32|UINT64)\((.+)\)')
> >
> > +            Re =
> > re.compile(r'(?:UINT8|UINT16|UINT32|UINT64)\((.+)\)')
> >
> >              try:
> >
> >                  RetValue = Re.search(Expr).group(1)
> >
> >              except:
> >
> > @@ -975,7 +975,7 @@ class ValueExpressionEx(ValueExpression):
> >                                  TokenSpaceGuidName = ''
> >
> >                                  if Item.startswith(TAB_GUID) and
> > Item.endswith(')'):
> >
> >                                      try:
> >
> > -                                        TokenSpaceGuidName =
> > re.search('GUID\((\w+)\)', Item).group(1)
> >
> > +                                        TokenSpaceGuidName =
> > 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 = []
> >  gGuidDict = {}
> >
> >
> >
> >  # definition for a MACRO name.  used to create regular expressions
> below.
> >
> > -_MacroNamePattern = "[A-Z][A-Z0-9_]*"
> >
> > +_MacroNamePattern = r"[A-Z][A-Z0-9_]*"
> >
> >
> >
> >  ## Regular expression for matching macro used in DSC/DEC/INF file
> inclusion
> >
> > -gMacroRefPattern = re.compile("\$\(({})\)".format(_MacroNamePattern),
> > re.UNICODE)
> >
> > +gMacroRefPattern = re.compile(r"\$\(({})\)".format(_MacroNamePattern),
> > re.UNICODE)
> >
> >  gMacroDefPattern = re.compile("^(DEFINE|EDK_GLOBAL)[ \t]+")
> >
> >  gMacroNamePattern = 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 = re.compile("\[\s*[0-9a-fA-FxX]*\s*\]")
> >
> > +ArrayIndex = re.compile(r"\[\s*[0-9a-fA-FxX]*\s*\]")
> >
> >  ## Regular expression used to find out place holders in string template
> >
> > -gPlaceholderPattern = re.compile("\$\{([^$()\s]+)\}", re.MULTILINE |
> > re.UNICODE)
> >
> > +gPlaceholderPattern = re.compile(r"\$\{([^$()\s]+)\}", re.MULTILINE |
> > re.UNICODE)
> >
> >
> >
> >  ## regular expressions for map file processing
> >
> > -startPatternGeneral = re.compile("^Start[' ']+Length[' ']+Name['
> ']+Class")
> >
> > -addressPatternGeneral = re.compile("^Address[' ']+Publics by Value['
> > ']+Rva\+Base")
> >
> > -valuePatternGcc = re.compile('^([\w_\.]+) +([\da-fA-Fx]+)
> +([\da-fA-Fx]+)$')
> >
> > -pcdPatternGcc = re.compile('^([\da-fA-Fx]+) +([\da-fA-Fx]+)')
> >
> > -secReGeneral = re.compile('^([\da-fA-F]+):([\da-fA-F]+)
> +([\da-fA-F]+)[Hh]?
> > +([.\w\$]+) +(\w+)', re.UNICODE)
> >
> > +startPatternGeneral = re.compile(r"^Start[' ']+Length[' ']+Name['
> ']+Class")
> >
> > +addressPatternGeneral = re.compile(r"^Address[' ']+Publics by Value['
> > ']+Rva\+Base")
> >
> > +valuePatternGcc = re.compile(r'^([\w_\.]+) +([\da-fA-Fx]+)
> +([\da-fA-Fx]+)$')
> >
> > +pcdPatternGcc = re.compile(r'^([\da-fA-Fx]+) +([\da-fA-Fx]+)')
> >
> > +secReGeneral = re.compile(r'^([\da-fA-F]+):([\da-fA-F]+)
> +([\da-fA-F]+)[Hh]?
> > +([.\w\$]+) +(\w+)', re.UNICODE)
> >
> >
> >
> >  StructPattern = re.compile(r'[_a-zA-Z][0-9A-Za-z_]*$')
> >
> >
> >
> > @@ -82,7 +82,7 @@ def GetVariableOffset(mapfilepath, efifilepath,
> > varnames):
> >
> >
> >      if len(lines) == 0: return None
> >
> >      firstline = 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 = []
> >
> >      for line in lines:
> >
> >          line = line.strip()
> >
> > -        if status == 0 and
> > (re.match('^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', line) \
> >
> > +        if status == 0 and
> > (re.match(r'^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', line) \
> >
> >              or line == "# Symbols:"):
> >
> >              status = 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 = re.match('^([\da-fA-FxX]+)([\s\S]*)([_]*%s)$' %
> > varname, line)
> >
> > +                    m = 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 = 0    #0 - beginning of file; 1 - PE section definition; 2 -
> symbol
> > table
> >
> >      secs  = []    # key = section name
> >
> >      varoffset = []
> >
> > -    symRe = re.compile('^([\da-fA-F]+):([\da-fA-F]+)
> +([\.:\\\\\w\?@\$-]+)
> > +([\da-fA-F]+)', re.UNICODE)
> >
> > +    symRe = re.compile(r'^([\da-fA-F]+):([\da-fA-F]+)
> +([\.:\\\\\w\?@\$-]+)
> > +([\da-fA-F]+)', re.UNICODE)
> >
> >
> >
> >      for line in lines:
> >
> >          line = 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=re.S)
> >
> > +    return re.sub(r'//.*?\n|/\*.*?\*/', '\n', ctext, flags=re.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 = re.compile('(DEF\([^\(\)]+\))')
> >
> > -gEnvRefPattern = re.compile('(ENV\([^\(\)]+\))')
> >
> > -gMacroDefPattern = re.compile("DEFINE\s+([^\s]+)")
> >
> > +gMacroRefPattern = re.compile(r'(DEF\([^\(\)]+\))')
> >
> > +gEnvRefPattern = re.compile(r'(ENV\([^\(\)]+\))')
> >
> > +gMacroDefPattern = re.compile(r"DEFINE\s+([^\s]+)")
> >
> >  gDefaultToolsDefFile = "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 = {"Auto", "8", "16", "32", "64", "128",
> > "512", "1K", "4K", "32K", "6
> >  ALIGNMENT_NOAUTO = ALIGNMENTS - {"Auto"}
> >
> >  CR_LB_SET = {T_CHAR_CR, TAB_LINE_BREAK}
> >
> >
> >
> > -RegionSizePattern =
> >
> compile("\s*(?P<base>(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P<size>(?:0x|0X)?[a-f
> > A-F0-9]+)\s*")
> >
> > -RegionSizeGuidPattern =
> > compile("\s*(?P<base>\w+\.\w+[\.\w\[\]]*)\s*\|\s*(?P<size>\w+\.\w+[\.\w
> > \[\]]*)\s*")
> >
> > -RegionOffsetPcdPattern = compile("\s*(?P<base>\w+\.\w+[\.\w\[\]]*)\s*$")
> >
> > -ShortcutPcdPattern =
> > compile("\s*\w+\s*=\s*(?P<value>(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P<name
> > >\w+\.\w+)\s*")
> >
> > -BaseAddrValuePattern = compile('^0[xX][0-9a-fA-F]+')
> >
> > +RegionSizePattern =
> >
> compile(r"\s*(?P<base>(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P<size>(?:0x|0X)?[a
> > -fA-F0-9]+)\s*")
> >
> > +RegionSizeGuidPattern =
> > compile(r"\s*(?P<base>\w+\.\w+[\.\w\[\]]*)\s*\|\s*(?P<size>\w+\.\w+[\.\w
> > \[\]]*)\s*")
> >
> > +RegionOffsetPcdPattern =
> > compile(r"\s*(?P<base>\w+\.\w+[\.\w\[\]]*)\s*$")
> >
> > +ShortcutPcdPattern =
> > compile(r"\s*\w+\s*=\s*(?P<value>(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P<name
> > >\w+\.\w+)\s*")
> >
> > +BaseAddrValuePattern = compile(r'^0[xX][0-9a-fA-F]+')
> >
> >  FileExtensionPattern = compile(r'([a-zA-Z][a-zA-Z0-9]*)')
> >
> >  TokenFindPattern =
> > compile(r'([a-zA-Z0-9\-]+|\$\(TARGET\)|\*)_([a-zA-Z0-9\-]+|\$\(TOOL_CHAI
> > N_TAG\)|\*)_([a-zA-Z0-9\-]+|\$\(ARCH\)|\*)')
> >
> >  AllIncludeFileList = []
> >
> > 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 = {}
> >
> > -                        ReFileEnds =
> >
>
> compile('\S+(.ui)$|\S+(fv.sec.txt)$|\S+(.pe32.txt)$|\S+(.te.txt)$|\S+(.pic.t
> xt)$
> > |\S+(.raw.txt)$|\S+(.ffs.txt)$')
> >
> > +                        ReFileEnds =
> >
>
> compile(r'\S+(.ui)$|\S+(fv.sec.txt)$|\S+(.pe32.txt)$|\S+(.te.txt)$|\S+(.pic.
> txt)$
> > |\S+(.raw.txt)$|\S+(.ffs.txt)$')
> >
> >                          FileList = os.listdir(FfsPath[0])
> >
> >                          for File in FileList:
> >
> >                              Match = 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__ = "Copyright (c) 2008 - 2018, Intel
> > Corporation. All rights reserv
> >  #======================================  Internal Libraries
> > ========================================
> >
> >
> >
> >  #============================================== Code
> > ===============================================
> >
> > -symRe = re.compile('^([\da-fA-F]+):([\da-fA-F]+)
> +([\.\-:\\\\\w\?@\$<>]+)
> > +([\da-fA-F]+)', re.UNICODE)
> >
> > +symRe = 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) == 0: return None
> >
> >      firstline = 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 =
> > re.compile('^([\da-fA-FxX]+)([\s\S]*)([_]*_gPcd_BinaryPatch_([\w]+))')
> >
> > +    valuePattern =
> > re.compile(r'^([\da-fA-FxX]+)([\s\S]*)([_]*_gPcd_BinaryPatch_([\w]+))')
> >
> >      status = 0
> >
> >      pcds = []
> >
> >      for line in lines:
> >
> >          line = line.strip()
> >
> > -        if status == 0 and
> > (re.match('^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', line) \
> >
> > +        if status == 0 and
> > (re.match(r'^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', line) \
> >
> >              or line == "# Symbols:"):
> >
> >              status = 1
> >
> >              continue
> >
> > @@ -77,7 +77,7 @@ def _parseForXcodeAndClang9(lines, efifilepath):
> >
> >
> >  def _parseForGCC(lines, efifilepath):
> >
> >      """ Parse map file generated by GCC linker """
> >
> > -    dataPattern = re.compile('^.data._gPcd_BinaryPatch_([\w_\d]+)$')
> >
> > +    dataPattern = re.compile(r'^.data._gPcd_BinaryPatch_([\w_\d]+)$')
> >
> >      status = 0
> >
> >      imageBase = -1
> >
> >      sections = []
> >
> > @@ -136,7 +136,7 @@ def _parseGeneral(lines, efifilepath):
> >      status = 0    #0 - beginning of file; 1 - PE section definition; 2 -
> symbol
> > table
> >
> >      secs = []    # key = section name
> >
> >      bPcds = []
> >
> > -    symPattern = re.compile('^[_]+gPcd_BinaryPatch_([\w]+)')
> >
> > +    symPattern = re.compile(r'^[_]+gPcd_BinaryPatch_([\w]+)')
> >
> >
> >
> >      for line in lines:
> >
> >          line = 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__ = "%prog Version " +
> > __version_number__
> >  __copyright__ = "Copyright (c) 2007-2018, Intel Corporation. All rights
> > reserved."
> >
> >
> >
> >  ## Regular expression for matching Line Control directive like "#line
> xxx"
> >
> > -gLineControlDirective =
> re.compile('^\s*#(?:line)?\s+([0-9]+)\s+"*([^"]*)"')
> >
> > +gLineControlDirective =
> re.compile(r'^\s*#(?:line)?\s+([0-9]+)\s+"*([^"]*)"')
> >
> >  ## Regular expression for matching "typedef struct"
> >
> > -gTypedefPattern = re.compile("^\s*typedef\s+struct(\s+\w+)?\s*[{]*$",
> > re.MULTILINE)
> >
> > +gTypedefPattern = re.compile(r"^\s*typedef\s+struct(\s+\w+)?\s*[{]*$",
> > re.MULTILINE)
> >
> >  ## Regular expression for matching "#pragma pack"
> >
> > -gPragmaPattern = re.compile("^\s*#pragma\s+pack", re.MULTILINE)
> >
> > +gPragmaPattern = re.compile(r"^\s*#pragma\s+pack", re.MULTILINE)
> >
> >  ## Regular expression for matching "typedef"
> >
> > -gTypedef_SinglePattern = re.compile("^\s*typedef", re.MULTILINE)
> >
> > +gTypedef_SinglePattern = re.compile(r"^\s*typedef", re.MULTILINE)
> >
> >  ## Regular expression for matching "typedef struct, typedef union,
> struct,
> > union"
> >
> > -gTypedef_MulPattern =
> > re.compile("^\s*(typedef)?\s+(struct|union)(\s+\w+)?\s*[{]*$",
> > re.MULTILINE)
> >
> > +gTypedef_MulPattern =
> > 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 =
> > 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 =
> >
>
> re.compile("(?<=[^a-zA-Z0-9_])(0[xX])([0-9a-fA-F]+)(U(?=$|[^a-zA-Z0-9_]))?")
> >
> > +gHexNumberPattern =
> >
>
> re.compile(r"(?<=[^a-zA-Z0-9_])(0[xX])([0-9a-fA-F]+)(U(?=$|[^a-zA-Z0-9_]))?"
> > )
> >
> >  ## Regular expression for matching decimal number with 'U' postfix
> >
> > -gDecNumberPattern =
> > re.compile("(?<=[^a-zA-Z0-9_])([0-9]+)U(?=$|[^a-zA-Z0-9_])")
> >
> > +gDecNumberPattern =
> > re.compile(r"(?<=[^a-zA-Z0-9_])([0-9]+)U(?=$|[^a-zA-Z0-9_])")
> >
> >  ## Regular expression for matching constant with 'ULL' 'LL' postfix
> >
> > -gLongNumberPattern =
> >
> re.compile("(?<=[^a-zA-Z0-9_])(0[xX][0-9a-fA-F]+|[0-9]+)U?LL(?=$|[^a-zA-Z0
> > -9_])")
> >
> > +gLongNumberPattern =
> >
> re.compile(r"(?<=[^a-zA-Z0-9_])(0[xX][0-9a-fA-F]+|[0-9]+)U?LL(?=$|[^a-zA-Z
> > 0-9_])")
> >
> >
> >
> >  ## Regular expression for matching "Include ()" in asl file
> >
> > -gAslIncludePattern =
> re.compile("^(\s*)[iI]nclude\s*\(\"?([^\"\(\)]+)\"\)",
> > re.MULTILINE)
> >
> > +gAslIncludePattern =
> re.compile(r"^(\s*)[iI]nclude\s*\(\"?([^\"\(\)]+)\"\)",
> > re.MULTILINE)
> >
> >  ## Regular expression for matching C style #include "XXX.asl" in asl
> file
> >
> >  gAslCIncludePattern =
> > 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 = '''
> >
> >
> >  WindowsCFLAGS = 'CFLAGS = $(CFLAGS) /wd4200 /wd4034 /wd4101 '
> >
> >  LinuxCFLAGS = 'CFLAGS += -Wno-pointer-to-int-cast -Wno-unused-variable '
> >
> > -PcdMakefileEnd = '''
> >
> > +PcdMakefileEnd = r'''
> >
> >  !INCLUDE $(BASE_TOOLS_PATH)\Source\C\Makefiles\ms.common
> >
> >  !INCLUDE $(BASE_TOOLS_PATH)\Source\C\Makefiles\ms.app
> >
> >  '''
> >
> > @@ -110,7 +110,7 @@ LIBS = -lCommon
> >  variablePattern = re.compile(r'[\t\s]*0[xX][a-fA-F0-9]+$')
> >
> >  SkuIdPattern = re.compile(r'^[a-zA-Z_][a-zA-Z0-9_]*$')
> >
> >  ## regular expressions for finding decimal and hex numbers
> >
> > -Pattern = re.compile('^[1-9]\d*|0$')
> >
> > +Pattern = re.compile(r'^[1-9]\d*|0$')
> >
> >  HexPattern = 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 = PcdMakefileHeader
> >
> >          if sys.platform == "win32":
> >
> > -            MakeApp = MakeApp + 'APPFILE = %s\%s.exe\n' %
> > (self.OutputPath, PcdValueInitName) + 'APPNAME = %s\n' %
> > (PcdValueInitName) + 'OBJECTS = %s\%s.obj %s.obj\n' % (self.OutputPath,
> > PcdValueInitName, os.path.join(self.OutputPath, PcdValueCommonName)) +
> > 'INC = '
> >
> > +            MakeApp = MakeApp + r'APPFILE = %s\%s.exe\n' %
> > (self.OutputPath, PcdValueInitName) + r'APPNAME = %s\n' %
> > (PcdValueInitName) + r'OBJECTS = %s\%s.obj %s.obj\n' % (self.OutputPath,
> > PcdValueInitName, os.path.join(self.OutputPath, PcdValueCommonName)) +
> > 'INC = '
> >
> >          else:
> >
> >              MakeApp = MakeApp + PcdGccMakefile
> >
> >              MakeApp = MakeApp + 'APPFILE = %s/%s\n' %
> > (self.OutputPath, PcdValueInitName) + 'APPNAME = %s\n' %
> > (PcdValueInitName) + 'OBJECTS = %s/%s.o %s.o\n' % (self.OutputPath,
> > PcdValueInitName, os.path.join(self.OutputPath, PcdValueCommonName)) + \
> >
> > @@ -2950,7 +2950,7 @@ class DscBuildData(PlatformBuildClassObject):
> >              MakeApp += "$(OBJECTS) : %s\n" % include_file
> >
> >          if sys.platform == "win32":
> >
> >              PcdValueCommonPath =
> > os.path.normpath(mws.join(GlobalData.gGlobalDefines["EDK_TOOLS_PATH"],
> > "Source\C\Common\PcdValueCommon.c"))
> >
> > -            MakeApp = MakeApp + '%s\PcdValueCommon.c : %s\n' %
> > (self.OutputPath, PcdValueCommonPath)
> >
> > +            MakeApp = MakeApp + r'%s\PcdValueCommon.c : %s\n' %
> > (self.OutputPath, PcdValueCommonPath)
> >
> >              MakeApp = MakeApp + '\tcopy /y %s $@\n' %
> > (PcdValueCommonPath)
> >
> >          else:
> >
> >              PcdValueCommonPath =
> > 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 = []
> >
> >          ArchList = set()
> >
> >          PrivateList = set()
> >
> > -        Line = re.sub(',[\s]*', TAB_COMMA_SPLIT, self._CurrentLine)
> >
> > +        Line = re.sub(r',[\s]*', TAB_COMMA_SPLIT, self._CurrentLine)
> >
> >          for Item in Line[1:-1].split(TAB_COMMA_SPLIT):
> >
> >              if Item == '':
> >
> >                  EdkLogger.error("Parser", FORMAT_UNKNOWN_ERROR,
> >
> > --
> > 2.43.0.windows.1
>
>
>
>


-=-=-=-=-=-=-=-=-=-=-=-
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]
-=-=-=-=-=-=-=-=-=-=-=-



[-- Attachment #2: Type: text/html, Size: 43828 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [edk2-devel] [PATCH v1 1/1] BaseTools: Resolve regex syntax warnings
  2023-12-06 20:27 ` [edk2-devel] [PATCH v1 1/1] BaseTools: " Joey Vagedes via groups.io
  2023-12-12  0:30   ` [edk2-devel] 回复: " gaoliming via groups.io
@ 2023-12-20 22:57   ` Rebecca Cran
  1 sibling, 0 replies; 6+ messages in thread
From: Rebecca Cran @ 2023-12-20 22:57 UTC (permalink / raw)
  To: Joey Vagedes, devel; +Cc: Liming Gao, Bob Feng, Yuwei Chen

Thanks.

Reviewed-by: Rebecca Cran <rebecca@bsdio.com>

-- 
Rebecca Cran

On 12/6/2023 1:27 PM, Joey Vagedes wrote:
> 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 <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>
> ---
>   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__ = """
>
> +__description__ = 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 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:
>       _SubSectionList = [_InputFile, _OutputFile, _Command]
>
>   
>
>       _PATH_SEP = "(+)"
>
> -    _FileTypePattern = re.compile("^[_a-zA-Z][_\-0-9a-zA-Z]*$")
>
> +    _FileTypePattern = re.compile(r"^[_a-zA-Z][_\-0-9a-zA-Z]*$")
>
>       _BinaryFileRule = 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 = re.compile("(\(|\)|\{[^{}]+\{?[^{}]+\}?[ ]*\}|\w+)")
>
> +    TokenPattern = 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 = 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 = re.compile("([_A-Z][_A-Z0-9]*)[ \t]*\((.+)\)", re.UNICODE)
>
> +gMacroPattern = re.compile(r"([_A-Z][_A-Z0-9]*)[ \t]*\((.+)\)", re.UNICODE)
>
>   
>
>   gIsFileMap = {}
>
>   
>
> 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 = re.compile('IMAGE_TOKEN *\(([A-Z0-9_]+) *\)', re.MULTILINE | re.UNICODE)
>
> +IMAGE_TOKEN = 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 = "0x00010017"
>   #
>
>   # Match name = variable
>
>   #
>
> -gEfiVarStoreNamePattern = re.compile("\s*name\s*=\s*(\w+)")
>
> +gEfiVarStoreNamePattern = re.compile(r"\s*name\s*=\s*(\w+)")
>
>   #
>
>   # The format of guid in efivarstore statement likes following and must be correct:
>
>   # guid = {0xA04A27f4, 0xDF00, 0x4D42, {0xB5, 0x52, 0x39, 0x51, 0x13, 0x02, 0x11, 0x3D}}
>
>   #
>
> -gEfiVarStoreGuidPattern = re.compile("\s*guid\s*=\s*({.*?{.*?}\s*})")
>
> +gEfiVarStoreGuidPattern = re.compile(r"\s*guid\s*=\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 = 'not referenced'
>   COMMENT_NOT_REFERENCED = ' ' + COMMENT + NOT_REFERENCED
>
>   CHAR_ARRAY_DEFIN = 'unsigned char'
>
>   COMMON_FILE_NAME = 'Strings'
>
> -STRING_TOKEN = re.compile('STRING_TOKEN *\(([A-Z0-9_]+) *\)', re.MULTILINE | re.UNICODE)
>
> +STRING_TOKEN = re.compile(r'STRING_TOKEN *\(([A-Z0-9_]+) *\)', re.MULTILINE | re.UNICODE)
>
>   
>
>   EFI_HII_ARRAY_SIZE_LENGTH = 4
>
>   EFI_HII_PACKAGE_HEADER_LENGTH = 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 = re.compile("(\(|\)|\w+| \S+\.inf)")
>
> +gDepexTokenPattern = re.compile(r"(\(|\)|\w+| \S+\.inf)")
>
>   
>
>   ## Regular expression for match: PCD(xxxx.yyy)
>
>   gPCDAsGuidPattern = 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          = 'Empty expression is not allowed.'
>   ERR_IN_OPERAND          = 'Macro after IN operator can only be: $(FAMILY), $(ARCH), $(TOOL_CHAIN_TAG) and $(TARGET).'
>
>   
>
>   __ValidString = re.compile(r'[_a-zA-Z][_0-9a-zA-Z]*$')
>
> -_ReLabel = re.compile('LABEL\((\w+)\)')
>
> -_ReOffset = re.compile('OFFSET_OF\((\w+)\)')
>
> +_ReLabel = re.compile(r'LABEL\((\w+)\)')
>
> +_ReOffset = re.compile(r'OFFSET_OF\((\w+)\)')
>
>   PcdPattern = 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 = re.compile("("
>
> -                                 "\$\([A-Z][A-Z0-9_]*\)|\$\(\w+\.\w+\)|\w+\.\w+|"
>
> -                                 "&&|\|\||!(?!=)|"
>
> -                                 "(?<=\W)AND(?=\W)|(?<=\W)OR(?=\W)|(?<=\W)NOT(?=\W)|(?<=\W)XOR(?=\W)|"
>
> -                                 "(?<=\W)EQ(?=\W)|(?<=\W)NE(?=\W)|(?<=\W)GT(?=\W)|(?<=\W)LT(?=\W)|(?<=\W)GE(?=\W)|(?<=\W)LE(?=\W)"
>
> +                                 r"\$\([A-Z][A-Z0-9_]*\)|\$\(\w+\.\w+\)|\w+\.\w+|"
>
> +                                 r"&&|\|\||!(?!=)|"
>
> +                                 r"(?<=\W)AND(?=\W)|(?<=\W)OR(?=\W)|(?<=\W)NOT(?=\W)|(?<=\W)XOR(?=\W)|"
>
> +                                 r"(?<=\W)EQ(?=\W)|(?<=\W)NE(?=\W)|(?<=\W)GT(?=\W)|(?<=\W)LT(?=\W)|(?<=\W)GE(?=\W)|(?<=\W)LE(?=\W)"
>
>                                  ")")
>
>   
>
>       @staticmethod
>
> @@ -737,7 +737,7 @@ class ValueExpression(BaseExpression):
>               self._Token = "'" + UStr + "'"
>
>               return self._Token
>
>           elif Expr.startswith('UINT'):
>
> -            Re = re.compile('(?:UINT8|UINT16|UINT32|UINT64)\((.+)\)')
>
> +            Re = re.compile(r'(?:UINT8|UINT16|UINT32|UINT64)\((.+)\)')
>
>               try:
>
>                   RetValue = Re.search(Expr).group(1)
>
>               except:
>
> @@ -975,7 +975,7 @@ class ValueExpressionEx(ValueExpression):
>                                   TokenSpaceGuidName = ''
>
>                                   if Item.startswith(TAB_GUID) and Item.endswith(')'):
>
>                                       try:
>
> -                                        TokenSpaceGuidName = re.search('GUID\((\w+)\)', Item).group(1)
>
> +                                        TokenSpaceGuidName = 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 = []
>   gGuidDict = {}
>
>   
>
>   # definition for a MACRO name.  used to create regular expressions below.
>
> -_MacroNamePattern = "[A-Z][A-Z0-9_]*"
>
> +_MacroNamePattern = r"[A-Z][A-Z0-9_]*"
>
>   
>
>   ## Regular expression for matching macro used in DSC/DEC/INF file inclusion
>
> -gMacroRefPattern = re.compile("\$\(({})\)".format(_MacroNamePattern), re.UNICODE)
>
> +gMacroRefPattern = re.compile(r"\$\(({})\)".format(_MacroNamePattern), re.UNICODE)
>
>   gMacroDefPattern = re.compile("^(DEFINE|EDK_GLOBAL)[ \t]+")
>
>   gMacroNamePattern = 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 = re.compile("\[\s*[0-9a-fA-FxX]*\s*\]")
>
> +ArrayIndex = re.compile(r"\[\s*[0-9a-fA-FxX]*\s*\]")
>
>   ## Regular expression used to find out place holders in string template
>
> -gPlaceholderPattern = re.compile("\$\{([^$()\s]+)\}", re.MULTILINE | re.UNICODE)
>
> +gPlaceholderPattern = re.compile(r"\$\{([^$()\s]+)\}", re.MULTILINE | re.UNICODE)
>
>   
>
>   ## regular expressions for map file processing
>
> -startPatternGeneral = re.compile("^Start[' ']+Length[' ']+Name[' ']+Class")
>
> -addressPatternGeneral = re.compile("^Address[' ']+Publics by Value[' ']+Rva\+Base")
>
> -valuePatternGcc = re.compile('^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-Fx]+)$')
>
> -pcdPatternGcc = re.compile('^([\da-fA-Fx]+) +([\da-fA-Fx]+)')
>
> -secReGeneral = re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\da-fA-F]+)[Hh]? +([.\w\$]+) +(\w+)', re.UNICODE)
>
> +startPatternGeneral = re.compile(r"^Start[' ']+Length[' ']+Name[' ']+Class")
>
> +addressPatternGeneral = re.compile(r"^Address[' ']+Publics by Value[' ']+Rva\+Base")
>
> +valuePatternGcc = re.compile(r'^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-Fx]+)$')
>
> +pcdPatternGcc = re.compile(r'^([\da-fA-Fx]+) +([\da-fA-Fx]+)')
>
> +secReGeneral = re.compile(r'^([\da-fA-F]+):([\da-fA-F]+) +([\da-fA-F]+)[Hh]? +([.\w\$]+) +(\w+)', re.UNICODE)
>
>   
>
>   StructPattern = re.compile(r'[_a-zA-Z][0-9A-Za-z_]*$')
>
>   
>
> @@ -82,7 +82,7 @@ def GetVariableOffset(mapfilepath, efifilepath, varnames):
>   
>
>       if len(lines) == 0: return None
>
>       firstline = 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 = []
>
>       for line in lines:
>
>           line = line.strip()
>
> -        if status == 0 and (re.match('^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', line) \
>
> +        if status == 0 and (re.match(r'^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', line) \
>
>               or line == "# Symbols:"):
>
>               status = 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 = re.match('^([\da-fA-FxX]+)([\s\S]*)([_]*%s)$' % varname, line)
>
> +                    m = 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 = 0    #0 - beginning of file; 1 - PE section definition; 2 - symbol table
>
>       secs  = []    # key = section name
>
>       varoffset = []
>
> -    symRe = re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\.:\\\\\w\?@\$-]+) +([\da-fA-F]+)', re.UNICODE)
>
> +    symRe = re.compile(r'^([\da-fA-F]+):([\da-fA-F]+) +([\.:\\\\\w\?@\$-]+) +([\da-fA-F]+)', re.UNICODE)
>
>   
>
>       for line in lines:
>
>           line = 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=re.S)
>
> +    return re.sub(r'//.*?\n|/\*.*?\*/', '\n', ctext, flags=re.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 = re.compile('(DEF\([^\(\)]+\))')
>
> -gEnvRefPattern = re.compile('(ENV\([^\(\)]+\))')
>
> -gMacroDefPattern = re.compile("DEFINE\s+([^\s]+)")
>
> +gMacroRefPattern = re.compile(r'(DEF\([^\(\)]+\))')
>
> +gEnvRefPattern = re.compile(r'(ENV\([^\(\)]+\))')
>
> +gMacroDefPattern = re.compile(r"DEFINE\s+([^\s]+)")
>
>   gDefaultToolsDefFile = "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 = {"Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K", "6
>   ALIGNMENT_NOAUTO = ALIGNMENTS - {"Auto"}
>
>   CR_LB_SET = {T_CHAR_CR, TAB_LINE_BREAK}
>
>   
>
> -RegionSizePattern = compile("\s*(?P<base>(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P<size>(?:0x|0X)?[a-fA-F0-9]+)\s*")
>
> -RegionSizeGuidPattern = compile("\s*(?P<base>\w+\.\w+[\.\w\[\]]*)\s*\|\s*(?P<size>\w+\.\w+[\.\w\[\]]*)\s*")
>
> -RegionOffsetPcdPattern = compile("\s*(?P<base>\w+\.\w+[\.\w\[\]]*)\s*$")
>
> -ShortcutPcdPattern = compile("\s*\w+\s*=\s*(?P<value>(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P<name>\w+\.\w+)\s*")
>
> -BaseAddrValuePattern = compile('^0[xX][0-9a-fA-F]+')
>
> +RegionSizePattern = compile(r"\s*(?P<base>(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P<size>(?:0x|0X)?[a-fA-F0-9]+)\s*")
>
> +RegionSizeGuidPattern = compile(r"\s*(?P<base>\w+\.\w+[\.\w\[\]]*)\s*\|\s*(?P<size>\w+\.\w+[\.\w\[\]]*)\s*")
>
> +RegionOffsetPcdPattern = compile(r"\s*(?P<base>\w+\.\w+[\.\w\[\]]*)\s*$")
>
> +ShortcutPcdPattern = compile(r"\s*\w+\s*=\s*(?P<value>(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P<name>\w+\.\w+)\s*")
>
> +BaseAddrValuePattern = compile(r'^0[xX][0-9a-fA-F]+')
>
>   FileExtensionPattern = compile(r'([a-zA-Z][a-zA-Z0-9]*)')
>
>   TokenFindPattern = compile(r'([a-zA-Z0-9\-]+|\$\(TARGET\)|\*)_([a-zA-Z0-9\-]+|\$\(TOOL_CHAIN_TAG\)|\*)_([a-zA-Z0-9\-]+|\$\(ARCH\)|\*)')
>
>   AllIncludeFileList = []
>
> 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 = {}
>
> -                        ReFileEnds = compile('\S+(.ui)$|\S+(fv.sec.txt)$|\S+(.pe32.txt)$|\S+(.te.txt)$|\S+(.pic.txt)$|\S+(.raw.txt)$|\S+(.ffs.txt)$')
>
> +                        ReFileEnds = compile(r'\S+(.ui)$|\S+(fv.sec.txt)$|\S+(.pe32.txt)$|\S+(.te.txt)$|\S+(.pic.txt)$|\S+(.raw.txt)$|\S+(.ffs.txt)$')
>
>                           FileList = os.listdir(FfsPath[0])
>
>                           for File in FileList:
>
>                               Match = 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__ = "Copyright (c) 2008 - 2018, Intel Corporation. All rights reserv
>   #======================================  Internal Libraries ========================================
>
>   
>
>   #============================================== Code ===============================================
>
> -symRe = re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\.\-:\\\\\w\?@\$<>]+) +([\da-fA-F]+)', re.UNICODE)
>
> +symRe = 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) == 0: return None
>
>       firstline = 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 = re.compile('^([\da-fA-FxX]+)([\s\S]*)([_]*_gPcd_BinaryPatch_([\w]+))')
>
> +    valuePattern = re.compile(r'^([\da-fA-FxX]+)([\s\S]*)([_]*_gPcd_BinaryPatch_([\w]+))')
>
>       status = 0
>
>       pcds = []
>
>       for line in lines:
>
>           line = line.strip()
>
> -        if status == 0 and (re.match('^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', line) \
>
> +        if status == 0 and (re.match(r'^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', line) \
>
>               or line == "# Symbols:"):
>
>               status = 1
>
>               continue
>
> @@ -77,7 +77,7 @@ def _parseForXcodeAndClang9(lines, efifilepath):
>   
>
>   def _parseForGCC(lines, efifilepath):
>
>       """ Parse map file generated by GCC linker """
>
> -    dataPattern = re.compile('^.data._gPcd_BinaryPatch_([\w_\d]+)$')
>
> +    dataPattern = re.compile(r'^.data._gPcd_BinaryPatch_([\w_\d]+)$')
>
>       status = 0
>
>       imageBase = -1
>
>       sections = []
>
> @@ -136,7 +136,7 @@ def _parseGeneral(lines, efifilepath):
>       status = 0    #0 - beginning of file; 1 - PE section definition; 2 - symbol table
>
>       secs = []    # key = section name
>
>       bPcds = []
>
> -    symPattern = re.compile('^[_]+gPcd_BinaryPatch_([\w]+)')
>
> +    symPattern = re.compile(r'^[_]+gPcd_BinaryPatch_([\w]+)')
>
>   
>
>       for line in lines:
>
>           line = 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__ = "%prog Version " + __version_number__
>   __copyright__ = "Copyright (c) 2007-2018, Intel Corporation. All rights reserved."
>
>   
>
>   ## Regular expression for matching Line Control directive like "#line xxx"
>
> -gLineControlDirective = re.compile('^\s*#(?:line)?\s+([0-9]+)\s+"*([^"]*)"')
>
> +gLineControlDirective = re.compile(r'^\s*#(?:line)?\s+([0-9]+)\s+"*([^"]*)"')
>
>   ## Regular expression for matching "typedef struct"
>
> -gTypedefPattern = re.compile("^\s*typedef\s+struct(\s+\w+)?\s*[{]*$", re.MULTILINE)
>
> +gTypedefPattern = re.compile(r"^\s*typedef\s+struct(\s+\w+)?\s*[{]*$", re.MULTILINE)
>
>   ## Regular expression for matching "#pragma pack"
>
> -gPragmaPattern = re.compile("^\s*#pragma\s+pack", re.MULTILINE)
>
> +gPragmaPattern = re.compile(r"^\s*#pragma\s+pack", re.MULTILINE)
>
>   ## Regular expression for matching "typedef"
>
> -gTypedef_SinglePattern = re.compile("^\s*typedef", re.MULTILINE)
>
> +gTypedef_SinglePattern = re.compile(r"^\s*typedef", re.MULTILINE)
>
>   ## Regular expression for matching "typedef struct, typedef union, struct, union"
>
> -gTypedef_MulPattern = re.compile("^\s*(typedef)?\s+(struct|union)(\s+\w+)?\s*[{]*$", re.MULTILINE)
>
> +gTypedef_MulPattern = 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 = 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 = re.compile("(?<=[^a-zA-Z0-9_])(0[xX])([0-9a-fA-F]+)(U(?=$|[^a-zA-Z0-9_]))?")
>
> +gHexNumberPattern = re.compile(r"(?<=[^a-zA-Z0-9_])(0[xX])([0-9a-fA-F]+)(U(?=$|[^a-zA-Z0-9_]))?")
>
>   ## Regular expression for matching decimal number with 'U' postfix
>
> -gDecNumberPattern = re.compile("(?<=[^a-zA-Z0-9_])([0-9]+)U(?=$|[^a-zA-Z0-9_])")
>
> +gDecNumberPattern = re.compile(r"(?<=[^a-zA-Z0-9_])([0-9]+)U(?=$|[^a-zA-Z0-9_])")
>
>   ## Regular expression for matching constant with 'ULL' 'LL' postfix
>
> -gLongNumberPattern = re.compile("(?<=[^a-zA-Z0-9_])(0[xX][0-9a-fA-F]+|[0-9]+)U?LL(?=$|[^a-zA-Z0-9_])")
>
> +gLongNumberPattern = re.compile(r"(?<=[^a-zA-Z0-9_])(0[xX][0-9a-fA-F]+|[0-9]+)U?LL(?=$|[^a-zA-Z0-9_])")
>
>   
>
>   ## Regular expression for matching "Include ()" in asl file
>
> -gAslIncludePattern = re.compile("^(\s*)[iI]nclude\s*\(\"?([^\"\(\)]+)\"\)", re.MULTILINE)
>
> +gAslIncludePattern = re.compile(r"^(\s*)[iI]nclude\s*\(\"?([^\"\(\)]+)\"\)", re.MULTILINE)
>
>   ## Regular expression for matching C style #include "XXX.asl" in asl file
>
>   gAslCIncludePattern = 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 = '''
>   
>
>   WindowsCFLAGS = 'CFLAGS = $(CFLAGS) /wd4200 /wd4034 /wd4101 '
>
>   LinuxCFLAGS = 'CFLAGS += -Wno-pointer-to-int-cast -Wno-unused-variable '
>
> -PcdMakefileEnd = '''
>
> +PcdMakefileEnd = r'''
>
>   !INCLUDE $(BASE_TOOLS_PATH)\Source\C\Makefiles\ms.common
>
>   !INCLUDE $(BASE_TOOLS_PATH)\Source\C\Makefiles\ms.app
>
>   '''
>
> @@ -110,7 +110,7 @@ LIBS = -lCommon
>   variablePattern = re.compile(r'[\t\s]*0[xX][a-fA-F0-9]+$')
>
>   SkuIdPattern = re.compile(r'^[a-zA-Z_][a-zA-Z0-9_]*$')
>
>   ## regular expressions for finding decimal and hex numbers
>
> -Pattern = re.compile('^[1-9]\d*|0$')
>
> +Pattern = re.compile(r'^[1-9]\d*|0$')
>
>   HexPattern = 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 = PcdMakefileHeader
>
>           if sys.platform == "win32":
>
> -            MakeApp = MakeApp + 'APPFILE = %s\%s.exe\n' % (self.OutputPath, PcdValueInitName) + 'APPNAME = %s\n' % (PcdValueInitName) + 'OBJECTS = %s\%s.obj %s.obj\n' % (self.OutputPath, PcdValueInitName, os.path.join(self.OutputPath, PcdValueCommonName)) + 'INC = '
>
> +            MakeApp = MakeApp + r'APPFILE = %s\%s.exe\n' % (self.OutputPath, PcdValueInitName) + r'APPNAME = %s\n' % (PcdValueInitName) + r'OBJECTS = %s\%s.obj %s.obj\n' % (self.OutputPath, PcdValueInitName, os.path.join(self.OutputPath, PcdValueCommonName)) + 'INC = '
>
>           else:
>
>               MakeApp = MakeApp + PcdGccMakefile
>
>               MakeApp = MakeApp + 'APPFILE = %s/%s\n' % (self.OutputPath, PcdValueInitName) + 'APPNAME = %s\n' % (PcdValueInitName) + 'OBJECTS = %s/%s.o %s.o\n' % (self.OutputPath, PcdValueInitName, os.path.join(self.OutputPath, PcdValueCommonName)) + \
>
> @@ -2950,7 +2950,7 @@ class DscBuildData(PlatformBuildClassObject):
>               MakeApp += "$(OBJECTS) : %s\n" % include_file
>
>           if sys.platform == "win32":
>
>               PcdValueCommonPath = os.path.normpath(mws.join(GlobalData.gGlobalDefines["EDK_TOOLS_PATH"], "Source\C\Common\PcdValueCommon.c"))
>
> -            MakeApp = MakeApp + '%s\PcdValueCommon.c : %s\n' % (self.OutputPath, PcdValueCommonPath)
>
> +            MakeApp = MakeApp + r'%s\PcdValueCommon.c : %s\n' % (self.OutputPath, PcdValueCommonPath)
>
>               MakeApp = MakeApp + '\tcopy /y %s $@\n' % (PcdValueCommonPath)
>
>           else:
>
>               PcdValueCommonPath = 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 = []
>
>           ArchList = set()
>
>           PrivateList = set()
>
> -        Line = re.sub(',[\s]*', TAB_COMMA_SPLIT, self._CurrentLine)
>
> +        Line = re.sub(r',[\s]*', TAB_COMMA_SPLIT, self._CurrentLine)
>
>           for Item in Line[1:-1].split(TAB_COMMA_SPLIT):
>
>               if Item == '':
>
>                   EdkLogger.error("Parser", FORMAT_UNKNOWN_ERROR,
>



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112774): https://edk2.groups.io/g/devel/message/112774
Mute This Topic: https://groups.io/mt/103021365/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [edk2-devel] [PATCH v1 0/1] Resolve regex syntax warnings
  2023-12-06 20:27 [edk2-devel] [PATCH v1 0/1] Resolve regex syntax warnings Joey Vagedes via groups.io
  2023-12-06 20:27 ` [edk2-devel] [PATCH v1 1/1] BaseTools: " Joey Vagedes via groups.io
@ 2023-12-20 23:51 ` Rebecca Cran
  1 sibling, 0 replies; 6+ messages in thread
From: Rebecca Cran @ 2023-12-20 23:51 UTC (permalink / raw)
  To: Joey Vagedes, devel; +Cc: Liming Gao, Bob Feng, Yuwei Chen

Queued as https://github.com/tianocore/edk2/pull/5178 .

On 12/6/2023 1:27 PM, Joey Vagedes wrote:
> Python 3.12 now produces syntax warnings when using an invalid escape
> character (\ followed by an unexpected character). This happens
> throughout BaseTools due the usage of regular expressions. the re module
> in python suggests that when creating regex patterns, to use raw text.
> This patch series adds the r prefix to any regex pattern that uses an
> invalid escape sequence.
>
> 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>
>
> Joey Vagedes (1):
>    BaseTools: Resolve regex syntax warnings
>
>   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(-)
>



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112776): https://edk2.groups.io/g/devel/message/112776
Mute This Topic: https://groups.io/mt/103021364/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-12-20 23:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-06 20:27 [edk2-devel] [PATCH v1 0/1] Resolve regex syntax warnings Joey Vagedes via groups.io
2023-12-06 20:27 ` [edk2-devel] [PATCH v1 1/1] BaseTools: " Joey Vagedes via groups.io
2023-12-12  0:30   ` [edk2-devel] 回复: " gaoliming via groups.io
2023-12-13 21:20     ` [edk2-devel] " Joey Vagedes via groups.io
2023-12-20 22:57   ` Rebecca Cran
2023-12-20 23:51 ` [edk2-devel] [PATCH v1 0/1] " Rebecca Cran

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox