From 85ecbd2a772c12d8523e18609f86c77c415ec016 Mon Sep 17 00:00:00 2001 From: Mark Mentovai Date: Tue, 11 Feb 2025 13:28:38 -0500 Subject: [PATCH] Fix SyntaxWarning in build/run_tests.py Use r-strings for all regular expressions. Fixes these warnings experienced with Python 3.12 (https://github.com/python/cpython/issues/98401, https://github.com/python/cpython/pull/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 Reviewed-by: Nico Weber --- build/run_tests.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build/run_tests.py b/build/run_tests.py index fcd346f9e..a85e93891 100755 --- a/build/run_tests.py +++ b/build/run_tests.py @@ -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) @@ -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' @@ -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. @@ -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)