Skip to content

Commit 2f57d9d

Browse files
authored
Merge pull request SCons#4501 from mwichmann/maint/py313-re
Fix a Python 3.13 problem in re.sub usage
2 parents 9beb493 + 9c97705 commit 2f57d9d

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
- Dump() with json format selected now recognizes additional compound types
1618
(UserDict and UserList), which improves the detail of the display.
1719
json output is also sorted, to match the default display.

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)