From 7b8f0bfa6e1a0390bea8e2b24d7d7fa33d654db3 Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Fri, 26 Jul 2024 12:02:33 -0700 Subject: [PATCH 1/2] patman: Resolve python string vs. regex escaping syntax Python strings have their own notion of backslash-escaping, and that can conflict with the intentions for strings passed to the 're' module. In particular, I get warnings like this: tools/patman/../patman/commit.py:9: SyntaxWarning: invalid escape sequence '\s' re_subject_tag = re.compile('([^:\s]*):\s*(.*)') We should use a raw string (r'...') so that all escaping is passed into the regex module, not interpreted within the string itself. Signed-off-by: Brian Norris Reviewed-by: Simon Glass --- tools/patman/commit.py | 2 +- tools/patman/patchstream.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/patman/commit.py b/tools/patman/commit.py index 684225c0e6..ce37a3d95e 100644 --- a/tools/patman/commit.py +++ b/tools/patman/commit.py @@ -6,7 +6,7 @@ import collections import re # Separates a tag: at the beginning of the subject from the rest of it -re_subject_tag = re.compile('([^:\s]*):\s*(.*)') +re_subject_tag = re.compile(r'([^:\s]*):\s*(.*)') class Commit: """Holds information about a single commit/patch in the series. diff --git a/tools/patman/patchstream.py b/tools/patman/patchstream.py index a09ae9c737..4955f6aaab 100644 --- a/tools/patman/patchstream.py +++ b/tools/patman/patchstream.py @@ -48,7 +48,7 @@ RE_TAG = re.compile('^(Tested-by|Acked-by|Reviewed-by|Patch-cc|Fixes): (.*)') RE_COMMIT = re.compile('^commit ([0-9a-f]*)$') # We detect these since checkpatch doesn't always do it -RE_SPACE_BEFORE_TAB = re.compile('^[+].* \t') +RE_SPACE_BEFORE_TAB = re.compile(r'^[+].* \t') # Match indented lines for changes RE_LEADING_WHITESPACE = re.compile(r'^\s') From 4597acbd5943a53afb8aeb9595f2ea5a40e1f99f Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 21 Aug 2024 17:52:24 -0600 Subject: [PATCH 2/2] qconfig: Fix an incorrect format-string with negative value This is not allowed, so use ljust() instead. This fixes the 'qconfig -i -I help' command. Signed-off-by: Simon Glass Fixes: 1bd43060b3e ("moveconfig: Use f strings where possible") --- tools/qconfig.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/qconfig.py b/tools/qconfig.py index 7b868c7d72..8c2fc9efc5 100755 --- a/tools/qconfig.py +++ b/tools/qconfig.py @@ -1595,7 +1595,7 @@ def imply(args): if flag == 'help' or bad: print("Imply flags: (separate with ',')") for name, info in IMPLY_FLAGS.items(): - print(f' {name:-15s}: {info[1]}') + print(f' {name.ljust(15)}: {info[1]}') return 1 imply_flags |= IMPLY_FLAGS[flag][0]