Skip to content

Commit 565cc84

Browse files
committed
fix(python): fix invalid escape sequences
1 parent fc21387 commit 565cc84

File tree

100 files changed

+321
-321
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+321
-321
lines changed

.github/workflows/version-check.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
def get_version_from_tag(tag):
9-
m = re.match("llvmorg-([0-9]+)\.([0-9]+)\.([0-9]+)(-rc[0-9]+)?$", tag)
9+
m = re.match(r"llvmorg-([0-9]+)\.([0-9]+)\.([0-9]+)(-rc[0-9]+)?$", tag)
1010
if m:
1111
if m.lastindex == 4:
1212
# We have an rc tag.

clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def main():
242242
filename = None
243243
lines_by_file = {}
244244
for line in sys.stdin:
245-
match = re.search('^\+\+\+\ "?(.*?/){%s}([^ \t\n"]*)' % args.p, line)
245+
match = re.search('^\\+\\+\\+\\ "?(.*?/){%s}([^ \t\n"]*)' % args.p, line)
246246
if match:
247247
filename = match.group(2)
248248
if filename is None:
@@ -255,7 +255,7 @@ def main():
255255
if not re.match("^%s$" % args.iregex, filename, re.IGNORECASE):
256256
continue
257257

258-
match = re.search("^@@.*\+(\d+)(,(\d+))?", line)
258+
match = re.search(r"^@@.*\+(\d+)(,(\d+))?", line)
259259
if match:
260260
start_line = int(match.group(1))
261261
line_count = 1

clang-tools-extra/docs/clang-tidy/checks/gen-static-analyzer-docs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def get_checkers(checkers_td, checkers_rst):
5959
"clang-analyzer-" + checker_package_prefix + "." + checker_name
6060
)
6161
anchor_url = re.sub(
62-
"\.", "-", checker_package_prefix + "." + checker_name
62+
r"\.", "-", checker_package_prefix + "." + checker_name
6363
).lower()
6464

6565
if not hidden and "alpha" not in full_package_name.lower():

clang/docs/tools/dump_ast_matchers.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ def extract_result_types(comment):
8686
parsed.
8787
"""
8888
result_types = []
89-
m = re.search(r"Usable as: Any Matcher[\s\n]*$", comment, re.S)
89+
m = re.search("Usable as: Any Matcher[\\s\n]*$", comment, re.S)
9090
if m:
9191
return ["*"]
9292
while True:
93-
m = re.match(r"^(.*)Matcher<([^>]+)>\s*,?[\s\n]*$", comment, re.S)
93+
m = re.match("^(.*)Matcher<([^>]+)>\\s*,?[\\s\n]*$", comment, re.S)
9494
if not m:
9595
if re.search(r"Usable as:\s*$", comment):
9696
return result_types
@@ -101,9 +101,9 @@ def extract_result_types(comment):
101101

102102

103103
def strip_doxygen(comment):
104-
"""Returns the given comment without \-escaped words."""
104+
r"""Returns the given comment without \-escaped words."""
105105
# If there is only a doxygen keyword in the line, delete the whole line.
106-
comment = re.sub(r"^\\[^\s]+\n", r"", comment, flags=re.M)
106+
comment = re.sub("^\\\\[^\\s]+\n", r"", comment, flags=re.M)
107107

108108
# If there is a doxygen \see command, change the \see prefix into "See also:".
109109
# FIXME: it would be better to turn this into a link to the target instead.
@@ -236,7 +236,7 @@ def act_on_decl(declaration, comment, allowed_types):
236236

237237
# Parse the various matcher definition macros.
238238
m = re.match(
239-
""".*AST_TYPE(LOC)?_TRAVERSE_MATCHER(?:_DECL)?\(
239+
r""".*AST_TYPE(LOC)?_TRAVERSE_MATCHER(?:_DECL)?\(
240240
\s*([^\s,]+\s*),
241241
\s*(?:[^\s,]+\s*),
242242
\s*AST_POLYMORPHIC_SUPPORTED_TYPES\(([^)]*)\)

clang/test/Analysis/check-analyzer-fixit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def run_test_once(args, extra_args):
5555
# themselves. We need to keep the comments to preserve line numbers while
5656
# avoiding empty lines which could potentially trigger formatting-related
5757
# checks.
58-
cleaned_test = re.sub("// *CHECK-[A-Z0-9\-]*:[^\r\n]*", "//", input_text)
58+
cleaned_test = re.sub("// *CHECK-[A-Z0-9\\-]*:[^\r\n]*", "//", input_text)
5959
write_file(temp_file_name, cleaned_test)
6060

6161
original_file_name = temp_file_name + ".orig"

compiler-rt/lib/asan/scripts/asan_symbolize.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ def symbolize(self, addr, binary, offset):
316316
# * For C functions atos omits parentheses and argument types.
317317
# * For C++ functions the function name (i.e., `foo` above) may contain
318318
# templates which may contain parentheses.
319-
match = re.match("^(.*) \(in (.*)\) \((.*:\d*)\)$", atos_line)
319+
match = re.match(r"^(.*) \(in (.*)\) \((.*:\d*)\)$", atos_line)
320320
logging.debug("atos_line: %s", atos_line)
321321
if match:
322322
function_name = match.group(1)
@@ -541,7 +541,7 @@ def process_line_posix(self, line):
541541
# names in the regex because it could be an
542542
# Objective-C or C++ demangled name.
543543
stack_trace_line_format = (
544-
"^( *#([0-9]+) *)(0x[0-9a-f]+) *(?:in *.+)? *\((.*)\+(0x[0-9a-f]+)\)"
544+
r"^( *#([0-9]+) *)(0x[0-9a-f]+) *(?:in *.+)? *\((.*)\+(0x[0-9a-f]+)\)"
545545
)
546546
match = re.match(stack_trace_line_format, line)
547547
if not match:

cross-project-tests/debuginfo-tests/dexter/dex/command/ParseCommand.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def get_address_object(address_name: str, offset: int = 0):
128128

129129

130130
def _search_line_for_cmd_start(line: str, start: int, valid_commands: dict) -> int:
131-
"""Scan `line` for a string matching any key in `valid_commands`.
131+
r"""Scan `line` for a string matching any key in `valid_commands`.
132132
133133
Start searching from `start`.
134134
Commands escaped with `\` (E.g. `\DexLabel('a')`) are ignored.
@@ -543,7 +543,7 @@ def test_parse_share_line(self):
543543
def test_parse_escaped(self):
544544
"""Escaped commands are ignored."""
545545

546-
lines = ['words \MockCmd("IGNORED") words words words\n']
546+
lines = ['words \\MockCmd("IGNORED") words words words\n']
547547

548548
values = self._find_all_mock_values_in_lines(lines)
549549

cross-project-tests/lit.cfg.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def can_target_host():
226226
xcode_lldb_vers = subprocess.check_output(["xcrun", "lldb", "--version"]).decode(
227227
"utf-8"
228228
)
229-
match = re.search("lldb-(\d+)", xcode_lldb_vers)
229+
match = re.search(r"lldb-(\d+)", xcode_lldb_vers)
230230
if match:
231231
apple_lldb_vers = int(match.group(1))
232232
if apple_lldb_vers < 1000:
@@ -250,7 +250,7 @@ def get_gdb_version_string():
250250
if len(gdb_vers_lines) < 1:
251251
print("Unkown GDB version format (too few lines)", file=sys.stderr)
252252
return None
253-
match = re.search("GNU gdb \(.*?\) ((\d|\.)+)", gdb_vers_lines[0].strip())
253+
match = re.search(r"GNU gdb \(.*?\) ((\d|\.)+)", gdb_vers_lines[0].strip())
254254
if match is None:
255255
print(f"Unkown GDB version format: {gdb_vers_lines[0]}", file=sys.stderr)
256256
return None
@@ -264,7 +264,7 @@ def get_clang_default_dwarf_version_string(triple):
264264
# Get the flags passed by the driver and look for -dwarf-version.
265265
cmd = f'{llvm_config.use_llvm_tool("clang")} -g -xc -c - -v -### --target={triple}'
266266
stderr = subprocess.run(cmd.split(), stderr=subprocess.PIPE).stderr.decode()
267-
match = re.search("-dwarf-version=(\d+)", stderr)
267+
match = re.search(r"-dwarf-version=(\d+)", stderr)
268268
if match is None:
269269
print("Cannot determine default dwarf version", file=sys.stderr)
270270
return None

libcxx/test/libcxx/transitive_includes.gen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
continue
6060

6161
# Escape slashes for the awk command below
62-
escaped_header = header.replace('/', '\/')
62+
escaped_header = header.replace('/', r'\/')
6363

6464
print(f"""\
6565
//--- {header}.sh.cpp

libcxx/utils/generate_escaped_output_table.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def compactPropertyRanges(input: list[PropertyRange]) -> list[PropertyRange]:
8484
return result
8585

8686

87-
DATA_ARRAY_TEMPLATE = """
87+
DATA_ARRAY_TEMPLATE = r"""
8888
/// The entries of the characters to escape in format's debug string.
8989
///
9090
/// Contains the entries for [format.string.escaped]/2.2.1.2.1

0 commit comments

Comments
 (0)