From: Adrian McCarthy Date: Fri, 7 Jun 2019 21:14:33 +0000 (+0000) Subject: Fix string literals to avoid deprecation warnings in regexp patterns X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=33bde05820bdb0f9eaba8cd4e57ed4e03430453f;p=llvm Fix string literals to avoid deprecation warnings in regexp patterns In LLDB, where tests run with the debug version of Python, we get a series of deprecation warnings because escape sequences like `\(` are being treated as part of the string literal rather than an escape for the regexp pattern. NFC intended. Differential Revision: https://reviews.llvm.org/D62882 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362846 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/utils/lit/lit/TestRunner.py b/utils/lit/lit/TestRunner.py index 07b0021385b..ab0df517bff 100644 --- a/utils/lit/lit/TestRunner.py +++ b/utils/lit/lit/TestRunner.py @@ -49,7 +49,7 @@ kDevNull = "/dev/null" # This regex captures ARG. ARG must not contain a right parenthesis, which # terminates %dbg. ARG must not contain quotes, in which ARG might be enclosed # during expansion. -kPdbgRegex = '%dbg\(([^)\'"]*)\)' +kPdbgRegex = '%dbg\\(([^)\'"]*)\\)' class ShellEnvironment(object): @@ -1420,14 +1420,14 @@ class IntegratedTestKeywordParser(object): # Trim trailing whitespace. line = line.rstrip() # Substitute line number expressions - line = re.sub('%\(line\)', str(line_number), line) + line = re.sub(r'%\(line\)', str(line_number), line) def replace_line_number(match): if match.group(1) == '+': return str(line_number + int(match.group(2))) if match.group(1) == '-': return str(line_number - int(match.group(2))) - line = re.sub('%\(line *([\+-]) *(\d+)\)', replace_line_number, line) + line = re.sub(r'%\(line *([\+-]) *(\d+)\)', replace_line_number, line) # Collapse lines with trailing '\\'. if output and output[-1][-1] == '\\': output[-1] = output[-1][:-1] + line