Skip to content

Commit 298e7cc

Browse files
committed
fix(lldb/**.py): fix invalid escape sequences
1 parent 314e9b1 commit 298e7cc

File tree

79 files changed

+285
-279
lines changed

Some content is hidden

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

79 files changed

+285
-279
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(

0 commit comments

Comments
 (0)