llvm.org GIT mirror llvm / 33bde05
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 Adrian McCarthy 2 months ago
1 changed file(s) with 3 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
4848 # This regex captures ARG. ARG must not contain a right parenthesis, which
4949 # terminates %dbg. ARG must not contain quotes, in which ARG might be enclosed
5050 # during expansion.
51 kPdbgRegex = '%dbg\(([^)\'"]*)\)'
51 kPdbgRegex = '%dbg\\(([^)\'"]*)\\)'
5252
5353 class ShellEnvironment(object):
5454
14191419 # Trim trailing whitespace.
14201420 line = line.rstrip()
14211421 # Substitute line number expressions
1422 line = re.sub('%\(line\)', str(line_number), line)
1422 line = re.sub(r'%\(line\)', str(line_number), line)
14231423
14241424 def replace_line_number(match):
14251425 if match.group(1) == '+':
14261426 return str(line_number + int(match.group(2)))
14271427 if match.group(1) == '-':
14281428 return str(line_number - int(match.group(2)))
1429 line = re.sub('%\(line *([\+-]) *(\d+)\)', replace_line_number, line)
1429 line = re.sub(r'%\(line *([\+-]) *(\d+)\)', replace_line_number, line)
14301430 # Collapse lines with trailing '\\'.
14311431 if output and output[-1][-1] == '\\':
14321432 output[-1] = output[-1][:-1] + line