Skip to content

Commit 0fed01a

Browse files
committed
fix(lldb/**.py): fix invalid escape sequences
1 parent f372bb4 commit 0fed01a

File tree

73 files changed

+263
-263
lines changed

Some content is hidden

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

73 files changed

+263
-263
lines changed

lldb/examples/python/crashlog.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ class DarwinImage(symbolication.Image):
296296
except:
297297
dsymForUUIDBinary = ""
298298

299-
dwarfdump_uuid_regex = re.compile("UUID: ([-0-9a-fA-F]+) \(([^\(]+)\) .*")
299+
dwarfdump_uuid_regex = re.compile(r"UUID: ([-0-9a-fA-F]+) \(([^\(]+)\) .*")
300300

301301
def __init__(
302302
self, text_addr_lo, text_addr_hi, identifier, version, uuid, path, verbose
@@ -501,7 +501,7 @@ def find_image_with_identifier(self, identifier):
501501
for image in self.images:
502502
if image.identifier == identifier:
503503
return image
504-
regex_text = "^.*\.%s$" % (re.escape(identifier))
504+
regex_text = r"^.*\.%s$" % (re.escape(identifier))
505505
regex = re.compile(regex_text)
506506
for image in self.images:
507507
if regex.match(image.identifier):
@@ -925,7 +925,7 @@ def get(cls):
925925
version = r"(?:" + super().version + r"\s+)?"
926926
address = r"(0x[0-9a-fA-F]{4,})" # 4 digits or more
927927

928-
symbol = """
928+
symbol = r"""
929929
(?:
930930
[ ]+
931931
(?P<symbol>.+)
@@ -1095,7 +1095,7 @@ def parse_normal(self, line):
10951095
self.crashlog.process_identifier = line[11:].strip()
10961096
elif line.startswith("Version:"):
10971097
version_string = line[8:].strip()
1098-
matched_pair = re.search("(.+)\((.+)\)", version_string)
1098+
matched_pair = re.search(r"(.+)\((.+)\)", version_string)
10991099
if matched_pair:
11001100
self.crashlog.process_version = matched_pair.group(1)
11011101
self.crashlog.process_compatability_version = matched_pair.group(2)

lldb/examples/python/delta.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def parse_log_file(file, options):
9999
print("# Log file: '%s'" % file)
100100
print("#----------------------------------------------------------------------")
101101

102-
timestamp_regex = re.compile("(\s*)([1-9][0-9]+\.[0-9]+)([^0-9].*)$")
102+
timestamp_regex = re.compile(r"(\s*)([1-9][0-9]+\.[0-9]+)([^0-9].*)$")
103103

104104
base_time = 0.0
105105
last_time = 0.0

lldb/examples/python/gdbremote.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,12 +1537,12 @@ def parse_gdb_log(file, options):
15371537
a long time during a preset set of debugger commands."""
15381538

15391539
tricky_commands = ["qRegisterInfo"]
1540-
timestamp_regex = re.compile("(\s*)([1-9][0-9]+\.[0-9]+)([^0-9].*)$")
1540+
timestamp_regex = re.compile(r"(\s*)([1-9][0-9]+\.[0-9]+)([^0-9].*)$")
15411541
packet_name_regex = re.compile("([A-Za-z_]+)[^a-z]")
15421542
packet_transmit_name_regex = re.compile(
15431543
"(?P<direction>send|read) packet: (?P<packet>.*)"
15441544
)
1545-
packet_contents_name_regex = re.compile("\$([^#]*)#[0-9a-fA-F]{2}")
1545+
packet_contents_name_regex = re.compile(r"\$([^#]*)#[0-9a-fA-F]{2}")
15461546
packet_checksum_regex = re.compile(".*#[0-9a-fA-F]{2}$")
15471547
packet_names_regex_str = "(" + "|".join(gdb_remote_commands.keys()) + ")(.*)"
15481548
packet_names_regex = re.compile(packet_names_regex_str)

lldb/examples/python/jump.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def parse_linespec(linespec, frame, result):
3838
)
3939

4040
if not matched:
41-
mo = re.match("^\+([0-9]+)$", linespec)
41+
mo = re.match(r"^\+([0-9]+)$", linespec)
4242
if mo is not None:
4343
matched = True
4444
# print "Matched +<count>"
@@ -54,7 +54,7 @@ def parse_linespec(linespec, frame, result):
5454
)
5555

5656
if not matched:
57-
mo = re.match("^\-([0-9]+)$", linespec)
57+
mo = re.match(r"^\-([0-9]+)$", linespec)
5858
if mo is not None:
5959
matched = True
6060
# print "Matched -<count>"
@@ -79,7 +79,7 @@ def parse_linespec(linespec, frame, result):
7979
breakpoint = target.BreakpointCreateByLocation(file_name, line_number)
8080

8181
if not matched:
82-
mo = re.match("\*((0x)?([0-9a-f]+))$", linespec)
82+
mo = re.match(r"\*((0x)?([0-9a-f]+))$", linespec)
8383
if mo is not None:
8484
matched = True
8585
# print "Matched <address-expression>"

lldb/examples/python/performance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ def __init__(self, pid):
346346

347347
def Measure(self):
348348
output = subprocess.getoutput(self.command).split("\n")[-1]
349-
values = re.split("[-+\s]+", output)
349+
values = re.split(r"[-+\s]+", output)
350350
for idx, stat in enumerate(values):
351351
multiplier = 1
352352
if stat:

lldb/examples/python/symbolication.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,9 @@ class Section:
177177
"""Class that represents an load address range"""
178178

179179
sect_info_regex = re.compile("(?P<name>[^=]+)=(?P<range>.*)")
180-
addr_regex = re.compile("^\s*(?P<start>0x[0-9A-Fa-f]+)\s*$")
180+
addr_regex = re.compile(r"^\s*(?P<start>0x[0-9A-Fa-f]+)\s*$")
181181
range_regex = re.compile(
182-
"^\s*(?P<start>0x[0-9A-Fa-f]+)\s*(?P<op>[-+])\s*(?P<end>0x[0-9A-Fa-f]+)\s*$"
182+
r"^\s*(?P<start>0x[0-9A-Fa-f]+)\s*(?P<op>[-+])\s*(?P<end>0x[0-9A-Fa-f]+)\s*$"
183183
)
184184

185185
def __init__(self, start_addr=None, end_addr=None, name=None):
@@ -557,7 +557,7 @@ def find_images_with_identifier(self, identifier):
557557
if image.identifier == identifier:
558558
images.append(image)
559559
if len(images) == 0:
560-
regex_text = "^.*\.%s$" % (re.escape(identifier))
560+
regex_text = r"^.*\.%s$" % (re.escape(identifier))
561561
regex = re.compile(regex_text)
562562
for image in self.images:
563563
if regex.match(image.identifier):

lldb/packages/Python/lldbsuite/test/lldbpexpect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,4 @@ def cursor_forward_escape_seq(self, chars_to_move):
104104
Returns the escape sequence to move the cursor forward/right
105105
by a certain amount of characters.
106106
"""
107-
return b"\x1b\[" + str(chars_to_move).encode("utf-8") + b"C"
107+
return b"\x1b\\[" + str(chars_to_move).encode("utf-8") + b"C"

lldb/packages/Python/lldbsuite/test/test_runner/process_control.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def timeout_to_seconds(timeout):
9191

9292

9393
class ProcessHelper(object):
94-
"""Provides an interface for accessing process-related functionality.
94+
r"""Provides an interface for accessing process-related functionality.
9595
9696
This class provides a factory method that gives the caller a
9797
platform-specific implementation instance of the class.

lldb/test/API/commands/command/backticks/TestBackticksInAlias.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ def test_backticks_in_alias(self):
2020
interp = self.dbg.GetCommandInterpreter()
2121
result = lldb.SBCommandReturnObject()
2222
interp.HandleCommand(
23-
"command alias _test-argv-cmd expression -Z \`argc\` -- argv", result
23+
r"command alias _test-argv-cmd expression -Z \`argc\` -- argv", result
2424
)
2525
self.assertCommandReturn(result, "Made the alias")
2626
interp.HandleCommand("_test-argv-cmd", result)
2727
self.assertCommandReturn(result, "The alias worked")
2828

2929
# Now try a harder case where we create this using an alias:
3030
interp.HandleCommand(
31-
"command alias _test-argv-parray-cmd parray \`argc\` argv", result
31+
r"command alias _test-argv-parray-cmd parray \`argc\` argv", result
3232
)
3333
self.assertCommandReturn(result, "Made the alias")
3434
interp.HandleCommand("_test-argv-parray-cmd", result)

lldb/test/API/commands/expression/memory-allocation/TestMemoryAllocSettings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def test(self):
3030
alloc0 = re.search("^.*IRMemoryMap::Malloc.+?0xdead0000.*$", log, re.MULTILINE)
3131
# Malloc adds additional bytes to allocation size, hence 10007
3232
alloc1 = re.search(
33-
"^.*IRMemoryMap::Malloc\s*?\(10007.+?0xdead1000.*$", log, re.MULTILINE
33+
r"^.*IRMemoryMap::Malloc\s*?\(10007.+?0xdead1000.*$", log, re.MULTILINE
3434
)
3535
self.assertTrue(alloc0, "Couldn't find an allocation at a given address.")
3636
self.assertTrue(

lldb/test/API/commands/expression/test/TestExprs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def build_and_run(self):
5050
def test_floating_point_expr_commands(self):
5151
self.build_and_run()
5252

53-
self.expect("expression 2.234f", patterns=["\(float\) \$.* = 2\.234"])
53+
self.expect("expression 2.234f", patterns=[r"\(float\) \$.* = 2\.234"])
5454
# (float) $2 = 2.234
5555

5656
def test_many_expr_commands(self):

lldb/test/API/commands/gui/expand-threads-tree/TestGuiExpandThreadsTree.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def test_gui(self):
4848
self.child.expect_exact("Threads")
4949

5050
# The main thread should be expanded.
51-
self.child.expect("#\d+: main")
51+
self.child.expect(r"#\d+: main")
5252

5353
# Quit the GUI
5454
self.child.send(escape_key)

lldb/test/API/commands/help/TestHelp.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,13 +349,13 @@ def test_help_show_tags(self):
349349
self.expect(
350350
"help memory read",
351351
patterns=[
352-
"--show-tags\n\s+Include memory tags in output "
353-
"\(does not apply to binary output\)."
352+
"--show-tags\n\\s+Include memory tags in output "
353+
"\\(does not apply to binary output\\)."
354354
],
355355
)
356356
self.expect(
357357
"help memory find",
358-
patterns=["--show-tags\n\s+Include memory tags in output."],
358+
patterns=["--show-tags\n\\s+Include memory tags in output."],
359359
)
360360

361361
@no_debug_info_test

lldb/test/API/commands/process/launch-with-shellexpand/TestLaunchWithShellExpand.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def test(self):
9393

9494
self.runCmd("process kill")
9595

96-
self.runCmd("process launch -X true -w %s -- foo\ bar" % (self.getBuildDir()))
96+
self.runCmd(r"process launch -X true -w %s -- foo\ bar" % (self.getBuildDir()))
9797

9898
process = self.process()
9999

lldb/test/API/commands/register/register/TestRegistersUnavailable.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ def test_unavailable_registers(self):
4848
"register read --all",
4949
patterns=[
5050
"(?sm)^general purpose registers:\n"
51-
"^\s+rdx = 0x5555555555555555\n"
51+
"^\\s+rdx = 0x5555555555555555\n"
5252
".*"
5353
"^3 registers were unavailable.\n"
5454
"\n"
5555
"^supplementary registers:\n"
56-
"^\s+edx = 0x55555555\n"
56+
"^\\s+edx = 0x55555555\n"
5757
".*"
5858
"^12 registers were unavailable."
5959
],

lldb/test/API/commands/settings/TestSettings.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,13 +186,13 @@ def cleanup():
186186
self.addTearDownHook(cleanup)
187187

188188
self.runCmd("settings show frame-format")
189-
m = re.match('^frame-format \(format-string\) = "(.*)"$', self.res.GetOutput())
189+
m = re.match(r'^frame-format \(format-string\) = "(.*)"$', self.res.GetOutput())
190190
self.assertTrue(m, "Bad settings string")
191191
self.format_string = m.group(1)
192192

193193
# Change the default format to print function.name rather than
194194
# function.name-with-args
195-
format_string = "frame #${frame.index}: ${frame.pc}{ ${module.file.basename}\`${function.name}{${function.pc-offset}}}{ at ${line.file.fullpath}:${line.number}}{, lang=${language}}\n"
195+
format_string = "frame #${frame.index}: ${frame.pc}{ ${module.file.basename}\\`${function.name}{${function.pc-offset}}}{ at ${line.file.fullpath}:${line.number}}{, lang=${language}}\n"
196196
self.runCmd("settings set frame-format %s" % format_string)
197197

198198
# Immediately test the setting.
@@ -671,7 +671,7 @@ def test_settings_with_trailing_whitespace(self):
671671
)
672672
self.runCmd("settings set target.run-args 1 2 3") # Set to known value
673673
# Set to new value with trailing whitespaces
674-
self.runCmd("settings set target.run-args 3 \ \ ")
674+
self.runCmd(r"settings set target.run-args 3 \ \ ")
675675
self.expect(
676676
"settings show target.run-args",
677677
SETTING_MSG("target.run-args"),
@@ -793,11 +793,11 @@ def test_settings_clear_all(self):
793793
# Check that settings have their default values after clearing.
794794
self.expect(
795795
"settings show target.env-vars",
796-
patterns=["^target.env-vars \(dictionary of strings\) =\s*$"],
796+
patterns=[r"^target.env-vars \(dictionary of strings\) =\s*$"],
797797
)
798798
self.expect(
799799
"settings show target.run-args",
800-
patterns=["^target.run-args \(arguments\) =\s*$"],
800+
patterns=[r"^target.run-args \(arguments\) =\s*$"],
801801
)
802802
self.expect("settings show auto-confirm", substrs=["false"])
803803
self.expect("settings show tab-size", substrs=["2"])
@@ -894,7 +894,7 @@ def test_experimental_settings(self):
894894
# showing & setting an undefined .experimental. setting should generate no errors.
895895
self.expect(
896896
"settings show target.experimental.setting-which-does-not-exist",
897-
patterns=["^\s$"],
897+
patterns=[r"^\s$"],
898898
error=False,
899899
)
900900
self.expect(

lldb/test/API/commands/target/basic/TestTargetCommand.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def do_target_command(self):
7474
# Find the largest index of the existing list.
7575
import re
7676

77-
pattern = re.compile("target #(\d+):")
77+
pattern = re.compile(r"target #(\d+):")
7878
for line in reversed(output.split(os.linesep)):
7979
match = pattern.search(line)
8080
if match:

lldb/test/API/commands/target/dump-separate-debug-info/dwo/TestDumpDwo.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ def test_dwos_loaded_table_output(self):
9494
self.expect(
9595
"target modules dump separate-debug-info",
9696
patterns=[
97-
"Symbol file: .*?a\.out",
97+
r"Symbol file: .*?a\.out",
9898
'Type: "dwo"',
99-
"Dwo ID\s+Err\s+Dwo Path",
100-
"0x[a-zA-Z0-9]{16}\s+.*main\.dwo",
101-
"0x[a-zA-Z0-9]{16}\s+.*foo\.dwo",
99+
r"Dwo ID\s+Err\s+Dwo Path",
100+
r"0x[a-zA-Z0-9]{16}\s+.*main\.dwo",
101+
r"0x[a-zA-Z0-9]{16}\s+.*foo\.dwo",
102102
],
103103
)
104104

@@ -118,11 +118,11 @@ def test_dwos_not_loaded_table_output(self):
118118
self.expect(
119119
"target modules dump separate-debug-info",
120120
patterns=[
121-
"Symbol file: .*?a\.out",
121+
r"Symbol file: .*?a\.out",
122122
'Type: "dwo"',
123-
"Dwo ID\s+Err\s+Dwo Path",
124-
"0x[a-zA-Z0-9]{16}\s+E\s+.*main\.dwo",
125-
"0x[a-zA-Z0-9]{16}\s+E\s+.*foo\.dwo",
123+
r"Dwo ID\s+Err\s+Dwo Path",
124+
r"0x[a-zA-Z0-9]{16}\s+E\s+.*main\.dwo",
125+
r"0x[a-zA-Z0-9]{16}\s+E\s+.*foo\.dwo",
126126
],
127127
)
128128

lldb/test/API/commands/target/dump-separate-debug-info/oso/TestDumpOso.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,11 @@ def test_shows_oso_loaded_table_output(self):
9393
self.expect(
9494
"target modules dump separate-debug-info",
9595
patterns=[
96-
"Symbol file: .*?a\.out",
96+
r"Symbol file: .*?a\.out",
9797
'Type: "oso"',
98-
"Mod Time\s+Err\s+Oso Path",
99-
"0x[a-zA-Z0-9]{16}\s+.*main\.o",
100-
"0x[a-zA-Z0-9]{16}\s+.*foo\.o",
98+
r"Mod Time\s+Err\s+Oso Path",
99+
r"0x[a-zA-Z0-9]{16}\s+.*main\.o",
100+
r"0x[a-zA-Z0-9]{16}\s+.*foo\.o",
101101
],
102102
)
103103

@@ -119,11 +119,11 @@ def test_shows_oso_not_loaded_table_output(self):
119119
self.expect(
120120
"target modules dump separate-debug-info",
121121
patterns=[
122-
"Symbol file: .*?a\.out",
122+
r"Symbol file: .*?a\.out",
123123
'Type: "oso"',
124-
"Mod Time\s+Err\s+Oso Path",
125-
"0x[a-zA-Z0-9]{16}\s+E\s+.*main\.o",
126-
"0x[a-zA-Z0-9]{16}\s+E\s+.*foo\.o",
124+
r"Mod Time\s+Err\s+Oso Path",
125+
r"0x[a-zA-Z0-9]{16}\s+E\s+.*main\.o",
126+
r"0x[a-zA-Z0-9]{16}\s+E\s+.*foo\.o",
127127
],
128128
)
129129

lldb/test/API/commands/trace/TestTraceDumpInfo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def testDumpRawTraceSize(self):
6464
hardware disabled tracing: 4
6565
trace synchronization point: 1""",
6666
],
67-
patterns=["Decoding instructions: \d.\d\ds"],
67+
patterns=[r"Decoding instructions: \d.\d\ds"],
6868
)
6969

7070
def testDumpRawTraceSizeJSON(self):

lldb/test/API/commands/trace/TestTraceEvents.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def testPauseEvents(self):
6868
self.expect(
6969
"thread trace dump instructions -e -f",
7070
patterns=[
71-
f"""thread #1: tid = .*
71+
fr"""thread #1: tid = .*
7272
0: \(event\) trace synchronization point \[offset \= 0x0xec0\]
7373
1: \(event\) hardware disabled tracing
7474
a.out`main \+ 23 at main.cpp:12
@@ -102,7 +102,7 @@ def testPauseEvents(self):
102102
self.expect(
103103
"thread trace dump instructions -e --id 18",
104104
patterns=[
105-
f"""thread #1: tid = .*
105+
fr"""thread #1: tid = .*
106106
a.out`symbol stub for: foo\(\)
107107
18: {ADDRESS_REGEX} jmpq .*
108108
17: \(event\) software disabled tracing

0 commit comments

Comments
 (0)