From 43c652959bff6ce815d7097c7cd1a5af97c96014 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Thu, 21 Mar 2024 11:57:14 -0600 Subject: [PATCH] Fix a Python 3.13 problem in re.sub usage re.sub's count and flags arguments are transitioning to keyword-only. With 3.13a5, usage as positional args issues a DeprecationWarning, which caused one SCons test to fail. Updated in test framework and in bin/update-release-info.py. Signed-off-by: Mats Wichmann --- CHANGES.txt | 2 ++ bin/update-release-info.py | 6 +++--- testing/framework/TestSCons.py | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 3fbdf061e5..021938a0d7 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -12,6 +12,8 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER From Mats Wichmann: - Updated Value Node docs and tests. + - Python 3.13 compat: re.sub deprecated count, flags as positional args, + caused update-release-info test to fail. RELEASE 4.7.0 - Sun, 17 Mar 2024 17:22:20 -0700 diff --git a/bin/update-release-info.py b/bin/update-release-info.py index 5e2e3265eb..c911fca38f 100644 --- a/bin/update-release-info.py +++ b/bin/update-release-info.py @@ -218,7 +218,7 @@ def __init__(self, file, orig=None): def sub(self, pattern, replacement, count=1): """ XXX """ - self.content = re.sub(pattern, replacement, self.content, count) + self.content = re.sub(pattern, replacement, self.content, count=count) def replace_assign(self, name, replacement, count=1): """ XXX """ @@ -226,11 +226,11 @@ def replace_assign(self, name, replacement, count=1): def replace_version(self, count=1): """ XXX """ - self.content = self.match_rel.sub(rel_info.version_string, self.content, count) + self.content = self.match_rel.sub(rel_info.version_string, self.content, count=count) def replace_date(self, count=1): """ XXX """ - self.content = self.match_date.sub(rel_info.new_date, self.content, count) + self.content = self.match_date.sub(rel_info.new_date, self.content, count=count) def __del__(self): """ XXX """ diff --git a/testing/framework/TestSCons.py b/testing/framework/TestSCons.py index e07be71d63..db702c69f0 100644 --- a/testing/framework/TestSCons.py +++ b/testing/framework/TestSCons.py @@ -668,14 +668,14 @@ def normalize_ps(self, s): return s @staticmethod - def to_bytes_re_sub(pattern, repl, str, count: int=0, flags: int=0): + def to_bytes_re_sub(pattern, repl, string, count: int=0, flags: int=0): """ Wrapper around re.sub to change pattern and repl to bytes to work with both python 2 & 3 """ pattern = to_bytes(pattern) repl = to_bytes(repl) - return re.sub(pattern, repl, str, count, flags) + return re.sub(pattern, repl, string, count=count, flags=flags) def normalize_pdf(self, s): s = self.to_bytes_re_sub(r'/(Creation|Mod)Date \(D:[^)]*\)',