Skip to content

Commit

Permalink
Fix SyntaxWarning in build/run_tests.py
Browse files Browse the repository at this point in the history
Use r-strings for all regular expressions.

Fixes these warnings experienced with Python 3.12
(python/cpython#98401,
python/cpython#99011,
https://docs.python.org/3/whatsnew/3.12.html#other-language-changes
point 2):

run_tests.py:200: SyntaxWarning: invalid escape sequence '\d'
  FINAL_LINE_RE = re.compile('status=(\d+)$')
run_tests.py:441: SyntaxWarning: invalid escape sequence '\*'
  re.match('^\* daemon .+ \*$', line) or line == ''):

Change-Id: I71ddfb1a2ca62654378ae67a99e9aeb4ce7b7394
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/6254063
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
  • Loading branch information
markmentovai authored and Crashpad LUCI CQ committed Feb 11, 2025
1 parent 4a227b2 commit 85ecbd2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions build/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def _BinaryDirTargetOS(binary_dir):
text=True)
value = popen.communicate()[0]
if popen.returncode == 0:
match = re.match('target_os = "(.*)"$', value)
match = re.match(r'target_os = "(.*)"$', value)
if match:
return match.group(1)

Expand All @@ -89,7 +89,7 @@ def _BinaryDirTargetOS(binary_dir):
if os.path.exists(build_ninja_path):
with open(build_ninja_path) as build_ninja_file:
build_ninja_content = build_ninja_file.read()
match = re.search('-linux-android(eabi)?-ar$', build_ninja_content,
match = re.search(r'-linux-android(eabi)?-ar$', build_ninja_content,
re.MULTILINE)
if match:
return 'android'
Expand Down Expand Up @@ -197,7 +197,7 @@ def _adb_shell(command_args, env={}):
stdout=subprocess.PIPE,
text=True)

FINAL_LINE_RE = re.compile('status=(\d+)$')
FINAL_LINE_RE = re.compile(r'status=(\d+)$')
final_line = None
while True:
# Use readline so that the test output appears “live” when running.
Expand Down Expand Up @@ -438,7 +438,7 @@ def main(args):
for line in adb_devices.splitlines():
line = line
if (line == 'List of devices attached' or
re.match('^\* daemon .+ \*$', line) or line == ''):
re.match(r'^\* daemon .+ \*$', line) or line == ''):
continue
(device, ignore) = line.split('\t')
devices.append(device)
Expand Down

0 comments on commit 85ecbd2

Please sign in to comment.