From: Brian Norris <computersforpeace@gmail.com>
To: Simon Glass <sjg@chromium.org>
Cc: u-boot@lists.denx.de, Brian Norris <computersforpeace@gmail.com>
Subject: [PATCH] patman: Resolve python string vs. regex escaping syntax
Date: Fri, 26 Jul 2024 12:02:33 -0700 [thread overview]
Message-ID: <20240726190240.167338-1-computersforpeace@gmail.com> (raw)
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 <computersforpeace@gmail.com>
---
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 684225c0e60d..ce37a3d95eb9 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 a09ae9c73714..4955f6aaab99 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')
--
2.43.0
next reply other threads:[~2024-07-26 19:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-26 19:02 Brian Norris [this message]
2024-07-28 19:36 ` [PATCH] patman: Resolve python string vs. regex escaping syntax Simon Glass
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240726190240.167338-1-computersforpeace@gmail.com \
--to=computersforpeace@gmail.com \
--cc=sjg@chromium.org \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox