mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 22:32:46 +00:00
Bug 1875052 - Change various RegEx patterns to raw strings to remove syntax warnings on Python 3.12 r=firefox-build-system-reviewers,glandium
Differential Revision: https://phabricator.services.mozilla.com/D199946
This commit is contained in:
parent
488ac1d1c5
commit
2914ac37f8
@ -67,7 +67,7 @@ def preprocess(base, input, flags):
|
||||
import re
|
||||
from collections import deque
|
||||
|
||||
IMPORT_RE = re.compile('import\s*"([^"]+)";')
|
||||
IMPORT_RE = re.compile(r'import\s*"([^"]+)";')
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("-I", action="append")
|
||||
|
@ -34,10 +34,10 @@ all_shared_architecture_names = set(
|
||||
["x86_shared", "arm", "arm64", "loong64", "riscv64", "wasm32"]
|
||||
)
|
||||
|
||||
reBeforeArg = "(?<=[(,\s])"
|
||||
reArgType = "(?P<type>[\w\s:*&<>]+)"
|
||||
reArgName = "(?P<name>\s\w+)"
|
||||
reArgDefault = "(?P<default>(?:\s=(?:(?:\s[\w:]+\(\))|[^,)]+))?)"
|
||||
reBeforeArg = r"(?<=[(,\s])"
|
||||
reArgType = r"(?P<type>[\w\s:*&<>]+)"
|
||||
reArgName = r"(?P<name>\s\w+)"
|
||||
reArgDefault = r"(?P<default>(?:\s=(?:(?:\s[\w:]+\(\))|[^,)]+))?)"
|
||||
reAfterArg = "(?=[,)])"
|
||||
reMatchArg = re.compile(reBeforeArg + reArgType + reArgName + reArgDefault + reAfterArg)
|
||||
|
||||
@ -52,7 +52,7 @@ def get_normalized_signatures(signature, fileAnnot=None):
|
||||
# Remove new-line induced spaces after opening braces.
|
||||
signature = re.sub(r"\(\s+", "(", signature).strip()
|
||||
# Match arguments, and keep only the type.
|
||||
signature = reMatchArg.sub("\g<type>", signature)
|
||||
signature = reMatchArg.sub(r"\g<type>", signature)
|
||||
# Remove class name
|
||||
signature = signature.replace("MacroAssembler::", "")
|
||||
|
||||
@ -63,7 +63,7 @@ def get_normalized_signatures(signature, fileAnnot=None):
|
||||
|
||||
if "DEFINED_ON(" in signature:
|
||||
archs = re.sub(
|
||||
r".*DEFINED_ON\((?P<archs>[^()]*)\).*", "\g<archs>", signature
|
||||
r".*DEFINED_ON\((?P<archs>[^()]*)\).*", r"\g<archs>", signature
|
||||
).split(",")
|
||||
archs = [a.strip() for a in archs]
|
||||
signature = re.sub(r"\s+DEFINED_ON\([^()]*\)", "", signature)
|
||||
|
@ -156,7 +156,7 @@ def preprocess(cxx, preprocessorOption, source, args=[]):
|
||||
def messages(jsmsg):
|
||||
defines = []
|
||||
for line in open(jsmsg):
|
||||
match = re.match("MSG_DEF\((JSMSG_(\w+))", line)
|
||||
match = re.match(r"MSG_DEF\((JSMSG_(\w+))", line)
|
||||
if match:
|
||||
defines.append("#define %s %i" % (match.group(1), len(defines)))
|
||||
continue
|
||||
|
@ -16,7 +16,7 @@ def codify(text):
|
||||
return text
|
||||
|
||||
|
||||
space_star_space_pat = re.compile("^\s*\* ?", re.M)
|
||||
space_star_space_pat = re.compile(r"^\s*\* ?", re.M)
|
||||
|
||||
|
||||
def get_comment_body(comment):
|
||||
@ -59,7 +59,7 @@ def parse_index(comment):
|
||||
index = []
|
||||
current_types = None
|
||||
category_name = ""
|
||||
category_pat = re.compile("\[([^\]]+)\]")
|
||||
category_pat = re.compile(r"\[([^\]]+)\]")
|
||||
for line in get_comment_body(comment):
|
||||
m = category_pat.search(line)
|
||||
if m:
|
||||
@ -166,7 +166,7 @@ def add_to_index(index, opcode):
|
||||
opcodes.append(opcode)
|
||||
|
||||
|
||||
tag_pat = re.compile("^\s*[A-Za-z]+:\s*|\s*$")
|
||||
tag_pat = re.compile(r"^\s*[A-Za-z]+:\s*|\s*$")
|
||||
|
||||
|
||||
def get_tag_value(line):
|
||||
|
@ -39,7 +39,7 @@ def process_define_file(output, input):
|
||||
|
||||
with open(path, "r") as input:
|
||||
r = re.compile(
|
||||
"^\s*#\s*(?P<cmd>[a-z]+)(?:\s+(?P<name>\S+)(?:\s+(?P<value>\S+))?)?", re.U
|
||||
r"^\s*#\s*(?P<cmd>[a-z]+)(?:\s+(?P<name>\S+)(?:\s+(?P<value>\S+))?)?", re.U
|
||||
)
|
||||
for l in input:
|
||||
m = r.match(l)
|
||||
|
@ -932,7 +932,7 @@ class ConfigureSandbox(dict):
|
||||
def wraps(self, func):
|
||||
return wraps(func)
|
||||
|
||||
RE_MODULE = re.compile("^[a-zA-Z0-9_.]+$")
|
||||
RE_MODULE = re.compile(r"^[a-zA-Z0-9_.]+$")
|
||||
|
||||
def imports_impl(self, _import, _from=None, _as=None):
|
||||
"""Implementation of @imports.
|
||||
|
@ -125,7 +125,7 @@ class Repository(object):
|
||||
if self._version:
|
||||
return self._version
|
||||
info = self._run("--version").strip()
|
||||
match = re.search("version ([^+)]+)", info)
|
||||
match = re.search(r"version ([^+)]+)", info)
|
||||
if not match:
|
||||
raise Exception("Unable to identify tool version.")
|
||||
|
||||
|
@ -182,7 +182,7 @@ class ParseError(Exception):
|
||||
|
||||
|
||||
class ExpressionParser(object):
|
||||
"""
|
||||
r"""
|
||||
A parser for a simple expression language.
|
||||
|
||||
The expression language can be described as follows::
|
||||
|
@ -28,7 +28,7 @@ def dependentlibs_win32_objdump(lib):
|
||||
)
|
||||
deps = []
|
||||
for line in proc.stdout:
|
||||
match = re.match("\s+DLL Name: (\S+)", line)
|
||||
match = re.match(r"\s+DLL Name: (\S+)", line)
|
||||
if match:
|
||||
# The DLL Name found might be mixed-case or upper-case. When cross-compiling,
|
||||
# the actual DLLs in dist/bin are all lowercase, whether they are produced
|
||||
@ -61,7 +61,7 @@ def dependentlibs_readelf(lib):
|
||||
# 0x00000001 (NEEDED) Shared library: [libname]
|
||||
# or with BSD readelf:
|
||||
# 0x00000001 NEEDED Shared library: [libname]
|
||||
match = re.search("\[(.*)\]", tmp[3])
|
||||
match = re.search(r"\[(.*)\]", tmp[3])
|
||||
if match:
|
||||
deps.append(match.group(1))
|
||||
proc.wait()
|
||||
|
Loading…
Reference in New Issue
Block a user