diff options
author | Mats Wichmann <mats@linux.com> | 2024-05-22 17:34:53 (GMT) |
---|---|---|
committer | Mats Wichmann <mats@linux.com> | 2024-05-22 17:34:53 (GMT) |
commit | 9f0e8476e0ca39a785e2806c2a40f2b7c0c95760 (patch) | |
tree | df7c69e4ce342ff1da7d385b6ae738173d618e4e | |
parent | ea5a851377872a69e21c71d0382b4fa7bf064baa (diff) | |
download | SCons-9f0e8476e0ca39a785e2806c2a40f2b7c0c95760.zip SCons-9f0e8476e0ca39a785e2806c2a40f2b7c0c95760.tar.gz SCons-9f0e8476e0ca39a785e2806c2a40f2b7c0c95760.tar.bz2 |
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 <mats@linux.com>
-rw-r--r-- | bin/SConsExamples.py | 2 | ||||
-rw-r--r-- | bin/scons-diff.py | 10 | ||||
-rw-r--r-- | bin/scons-time.py | 2 |
3 files changed, 7 insertions, 7 deletions
diff --git a/bin/SConsExamples.py b/bin/SConsExamples.py index 46df103..e7a20ce 100644 --- a/bin/SConsExamples.py +++ b/bin/SConsExamples.py @@ -554,7 +554,7 @@ def CCCom(target, source, env): process(src, fp) fp.write('debug = ' + ARGUMENTS.get('debug', '0') + '\\n') -public_class_re = re.compile('^public class (\S+)', re.MULTILINE) +public_class_re = re.compile(r'^public class (\S+)', re.MULTILINE) def JavaCCom(target, source, env): # This is a fake Java compiler that just looks for diff --git a/bin/scons-diff.py b/bin/scons-diff.py index da5ae76..b1b2eec 100644 --- a/bin/scons-diff.py +++ b/bin/scons-diff.py @@ -115,11 +115,11 @@ diff_map = { diff_function = diff_map.get(diff_type, simple_diff) -baseline_re = re.compile('(# |@REM )/home/\S+/baseline/') -comment_rev_re = re.compile('(# |@REM )(\S+) 0.96.[CD]\d+ \S+ \S+( knight)') -revision_re = re.compile('__revision__ = "[^"]*"') -build_re = re.compile('__build__ = "[^"]*"') -date_re = re.compile('__date__ = "[^"]*"') +baseline_re = re.compile(r'(# |@REM )/home/\S+/baseline/') +comment_rev_re = re.compile(r'(# |@REM )(\S+) 0.96.[CD]\d+ \S+ \S+( knight)') +revision_re = re.compile(r'__revision__ = "[^"]*"') +build_re = re.compile(r'__build__ = "[^"]*"') +date_re = re.compile(r'__date__ = "[^"]*"') def lines_read(file): return open(file).readlines() diff --git a/bin/scons-time.py b/bin/scons-time.py index 817a953..c8121fb 100644 --- a/bin/scons-time.py +++ b/bin/scons-time.py @@ -552,7 +552,7 @@ class SConsTimer: specified prefix, extracts the run numbers from each file name, and returns the next run number after the largest it finds. """ - x = re.compile(re.escape(prefix) + '-([0-9]+).*') + x = re.compile(re.escape(prefix) + r'-([0-9]+).*') matches = [x.match(e) for e in os.listdir(dir)] matches = [_f for _f in matches if _f] if not matches: |