Skip to content

Commit 43c6529

Browse files
committed
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 <[email protected]>
1 parent 04c86e1 commit 43c6529

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
1212
From Mats Wichmann:
1313

1414
- Updated Value Node docs and tests.
15+
- Python 3.13 compat: re.sub deprecated count, flags as positional args,
16+
caused update-release-info test to fail.
1517

1618

1719
RELEASE 4.7.0 - Sun, 17 Mar 2024 17:22:20 -0700

bin/update-release-info.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,19 +218,19 @@ def __init__(self, file, orig=None):
218218

219219
def sub(self, pattern, replacement, count=1):
220220
""" XXX """
221-
self.content = re.sub(pattern, replacement, self.content, count)
221+
self.content = re.sub(pattern, replacement, self.content, count=count)
222222

223223
def replace_assign(self, name, replacement, count=1):
224224
""" XXX """
225225
self.sub('\n' + name + ' = .*', '\n' + name + ' = ' + replacement)
226226

227227
def replace_version(self, count=1):
228228
""" XXX """
229-
self.content = self.match_rel.sub(rel_info.version_string, self.content, count)
229+
self.content = self.match_rel.sub(rel_info.version_string, self.content, count=count)
230230

231231
def replace_date(self, count=1):
232232
""" XXX """
233-
self.content = self.match_date.sub(rel_info.new_date, self.content, count)
233+
self.content = self.match_date.sub(rel_info.new_date, self.content, count=count)
234234

235235
def __del__(self):
236236
""" XXX """

testing/framework/TestSCons.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -668,14 +668,14 @@ def normalize_ps(self, s):
668668
return s
669669

670670
@staticmethod
671-
def to_bytes_re_sub(pattern, repl, str, count: int=0, flags: int=0):
671+
def to_bytes_re_sub(pattern, repl, string, count: int=0, flags: int=0):
672672
"""
673673
Wrapper around re.sub to change pattern and repl to bytes to work with
674674
both python 2 & 3
675675
"""
676676
pattern = to_bytes(pattern)
677677
repl = to_bytes(repl)
678-
return re.sub(pattern, repl, str, count, flags)
678+
return re.sub(pattern, repl, string, count=count, flags=flags)
679679

680680
def normalize_pdf(self, s):
681681
s = self.to_bytes_re_sub(r'/(Creation|Mod)Date \(D:[^)]*\)',

0 commit comments

Comments
 (0)