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 <lgrey@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
This commit is contained in:
Mark Mentovai 2025-02-24 23:32:25 -05:00 committed by Crashpad LUCI CQ
parent 4d14c1be03
commit 51eba29eee
3 changed files with 7 additions and 6 deletions

View File

@ -89,8 +89,9 @@ def _BinaryDirTargetOS(binary_dir):
if os.path.exists(build_ninja_path): if os.path.exists(build_ninja_path):
with open(build_ninja_path) as build_ninja_file: with open(build_ninja_path) as build_ninja_file:
build_ninja_content = build_ninja_file.read() build_ninja_content = build_ninja_file.read()
match = re.search(r'-linux-android(eabi)?-ar$', build_ninja_content, match = re.search(r'-linux-android(eabi)?-ar$',
re.MULTILINE) build_ninja_content,
flags=re.MULTILINE)
if match: if match:
return 'android' return 'android'

View File

@ -237,7 +237,7 @@ class CdbRun(object):
[cdb_path, '-z', dump_path, '-c', command + ';q'], text=True) [cdb_path, '-z', dump_path, '-c', command + ';q'], text=True)
def Check(self, pattern, message, re_flags=0, must_not_match=False): 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: if match_obj and not must_not_match:
# Matched. Consume up to end of match. # Matched. Consume up to end of match.
self.out = self.out[match_obj.end(0):] self.out = self.out[match_obj.end(0):]
@ -263,7 +263,7 @@ class CdbRun(object):
g_had_failures = True g_had_failures = True
def Find(self, pattern, re_flags=0): 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: if match_obj:
# Matched. Consume up to end of match. # Matched. Consume up to end of match.
self.out = self.out[match_obj.end(0):] self.out = self.out[match_obj.end(0):]

View File

@ -69,7 +69,7 @@ def _fix_user_implementation(implementation, fixed_implementation, header,
file = open(implementation, 'r+' if fixed_implementation is None else 'r') file = open(implementation, 'r+' if fixed_implementation is None else 'r')
contents = file.read() 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) contents = pattern.sub(r'\1 __attribute__((unused));', contents)
if fixed_header is not None: if fixed_header is not None:
@ -112,7 +112,7 @@ def _fix_server_implementation(implementation, fixed_implementation, header,
# Find interesting declarations. # Find interesting declarations.
declaration_pattern = re.compile( 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) declarations = declaration_pattern.findall(contents)
# Remove “__attribute__((__unused__))” from the declarations, and call them # Remove “__attribute__((__unused__))” from the declarations, and call them