Skip to content

Commit 87f3b8f

Browse files
committed
[lldb/crashlog] Use raw strings to silence escape sequence warnings
This patch silences from escapte sequence warnings from the crashlog script that were mostly due to regular expression strings. This is addresses by using raw strings so the escape character isn't interpreted by python and gets passed straight to the regular expression engine. Signed-off-by: Med Ismail Bennani <[email protected]>
1 parent 720e920 commit 87f3b8f

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
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/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):

0 commit comments

Comments
 (0)