Skip to content

Commit 9f0e847

Browse files
committed
Fix some more regex strings
Building the userguide examples with Python 3.12 led to SyntaxWarning lines appearing in the output. The reason was a regex string that contained an escape sequence that is not one of the Python escapes, and the string wasn't entered in raw-string format - 3.12 compains about this. This sort of problem has been fixed elsewhere, but missed some cases in the tools. Continuing on with the rule "if it's a regex, use raw string format". Signed-off-by: Mats Wichmann <[email protected]>
1 parent ea5a851 commit 9f0e847

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

bin/SConsExamples.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ def process(source_file, ofp):
554554
process(src, fp)
555555
fp.write('debug = ' + ARGUMENTS.get('debug', '0') + '\\n')
556556
557-
public_class_re = re.compile('^public class (\S+)', re.MULTILINE)
557+
public_class_re = re.compile(r'^public class (\S+)', re.MULTILINE)
558558
559559
def JavaCCom(target, source, env):
560560
# This is a fake Java compiler that just looks for

bin/scons-diff.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,11 @@ def comma(x1, x2):
115115

116116
diff_function = diff_map.get(diff_type, simple_diff)
117117

118-
baseline_re = re.compile('(# |@REM )/home/\S+/baseline/')
119-
comment_rev_re = re.compile('(# |@REM )(\S+) 0.96.[CD]\d+ \S+ \S+( knight)')
120-
revision_re = re.compile('__revision__ = "[^"]*"')
121-
build_re = re.compile('__build__ = "[^"]*"')
122-
date_re = re.compile('__date__ = "[^"]*"')
118+
baseline_re = re.compile(r'(# |@REM )/home/\S+/baseline/')
119+
comment_rev_re = re.compile(r'(# |@REM )(\S+) 0.96.[CD]\d+ \S+ \S+( knight)')
120+
revision_re = re.compile(r'__revision__ = "[^"]*"')
121+
build_re = re.compile(r'__build__ = "[^"]*"')
122+
date_re = re.compile(r'__date__ = "[^"]*"')
123123

124124
def lines_read(file):
125125
return open(file).readlines()

bin/scons-time.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ def find_next_run_number(self, dir, prefix):
552552
specified prefix, extracts the run numbers from each file name,
553553
and returns the next run number after the largest it finds.
554554
"""
555-
x = re.compile(re.escape(prefix) + '-([0-9]+).*')
555+
x = re.compile(re.escape(prefix) + r'-([0-9]+).*')
556556
matches = [x.match(e) for e in os.listdir(dir)]
557557
matches = [_f for _f in matches if _f]
558558
if not matches:

0 commit comments

Comments
 (0)