[PATCH] D62882: Use raw strings to avoid deprecation warnings in regexp patterns
Adrian McCarthy via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 4 15:53:14 PDT 2019
amccarth created this revision.
amccarth added reviewers: rnk, jdenny.
Herald added a subscriber: delcypher.
Herald added a project: LLVM.
In LLDB, where tests run with the debug version of Python, we get a series of deprecation warnings because `\(` escape sequences are treated as part of the string literal rather than an escaped paren for the regexp pattern.
I believe the change preserves the original intent rather than the actual behavior when running with Python 3, but another pair of eyes would be appreciated.
https://reviews.llvm.org/D62882
Files:
llvm/utils/lit/lit/TestRunner.py
Index: llvm/utils/lit/lit/TestRunner.py
===================================================================
--- llvm/utils/lit/lit/TestRunner.py
+++ llvm/utils/lit/lit/TestRunner.py
@@ -49,7 +49,7 @@
# 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 = r'%dbg\(([^)\'"]*)\)'
class ShellEnvironment(object):
@@ -1420,14 +1420,14 @@
# 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62882.203041.patch
Type: text/x-patch
Size: 1293 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190604/8ddcd5cd/attachment.bin>
More information about the llvm-commits
mailing list