From 51eba29eeee96663374dea13de79bac3710d99fe Mon Sep 17 00:00:00 2001 From: Mark Mentovai Date: Mon, 24 Feb 2025 23:32:25 -0500 Subject: [PATCH] Fix Python 3.13 re DeprecationWarning: pass count and flags by keyword https://docs.python.org/3/library/re.html: > Deprecated since version 3.13: Passing count and flags as positional > arguments is deprecated. In future Python versions they will be > keyword-only parameters. https://github.com/python/cpython/issues/56166, https://github.com/python/cpython/pull/107778, https://docs.python.org/3/whatsnew/3.13.html#:~:text=gh%2D66543.)-,re%3A,-Deprecate%20passing%20the Change-Id: Ibda1394927062dd9e0353e2b9d643b510070deb6 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/6298792 Reviewed-by: Leonard Grey Commit-Queue: Mark Mentovai --- build/run_tests.py | 5 +++-- snapshot/win/end_to_end_test.py | 4 ++-- util/mach/mig_fix.py | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/build/run_tests.py b/build/run_tests.py index a85e9389..014dc03d 100755 --- a/build/run_tests.py +++ b/build/run_tests.py @@ -89,8 +89,9 @@ 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(r'-linux-android(eabi)?-ar$', build_ninja_content, - re.MULTILINE) + match = re.search(r'-linux-android(eabi)?-ar$', + build_ninja_content, + flags=re.MULTILINE) if match: return 'android' diff --git a/snapshot/win/end_to_end_test.py b/snapshot/win/end_to_end_test.py index 25f661c1..b00b3e54 100755 --- a/snapshot/win/end_to_end_test.py +++ b/snapshot/win/end_to_end_test.py @@ -237,7 +237,7 @@ class CdbRun(object): [cdb_path, '-z', dump_path, '-c', command + ';q'], text=True) def Check(self, pattern, message, re_flags=0, must_not_match=False): - match_obj = re.search(pattern, self.out, re_flags) + match_obj = re.search(pattern, self.out, flags=re_flags) if match_obj and not must_not_match: # Matched. Consume up to end of match. self.out = self.out[match_obj.end(0):] @@ -263,7 +263,7 @@ class CdbRun(object): g_had_failures = True def Find(self, pattern, re_flags=0): - match_obj = re.search(pattern, self.out, re_flags) + match_obj = re.search(pattern, self.out, flags=re_flags) if match_obj: # Matched. Consume up to end of match. self.out = self.out[match_obj.end(0):] diff --git a/util/mach/mig_fix.py b/util/mach/mig_fix.py index 79d9a6ed..2151ad22 100755 --- a/util/mach/mig_fix.py +++ b/util/mach/mig_fix.py @@ -69,7 +69,7 @@ def _fix_user_implementation(implementation, fixed_implementation, header, file = open(implementation, 'r+' if fixed_implementation is None else 'r') contents = file.read() - pattern = re.compile('^(\t} __Reply);$', re.MULTILINE) + pattern = re.compile('^(\t} __Reply);$', flags=re.MULTILINE) contents = pattern.sub(r'\1 __attribute__((unused));', contents) if fixed_header is not None: @@ -112,7 +112,7 @@ def _fix_server_implementation(implementation, fixed_implementation, header, # Find interesting declarations. declaration_pattern = re.compile( - '^mig_internal (kern_return_t __MIG_check__.*)$', re.MULTILINE) + '^mig_internal (kern_return_t __MIG_check__.*)$', flags=re.MULTILINE) declarations = declaration_pattern.findall(contents) # Remove “__attribute__((__unused__))” from the declarations, and call them