All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xen/x86: Fix Syntax warning in gen-cpuid.py
@ 2024-04-26  4:07 Jason Andryuk
  2024-04-26 19:07 ` Andrew Cooper
  0 siblings, 1 reply; 2+ messages in thread
From: Jason Andryuk @ 2024-04-26  4:07 UTC (permalink / raw
  To: xen-devel; +Cc: Jason Andryuk, Jan Beulich, Andrew Cooper, Roger Pau Monné

Python 3.12.2 warns:

xen/tools/gen-cpuid.py:50: SyntaxWarning: invalid escape sequence '\s'
  "\s+([\s\d]+\*[\s\d]+\+[\s\d]+)\)"
xen/tools/gen-cpuid.py:51: SyntaxWarning: invalid escape sequence '\s'
  "\s+/\*([\w!]*) .*$")

Specify the strings as raw strings so '\s' is read as literal '\' + 's'.
This avoids escaping all the '\'s in the strings.

Signed-off-by: Jason Andryuk <jason.andryuk@amd.com>
---
 xen/tools/gen-cpuid.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xen/tools/gen-cpuid.py b/xen/tools/gen-cpuid.py
index bf3f9ec01e..dadeb33080 100755
--- a/xen/tools/gen-cpuid.py
+++ b/xen/tools/gen-cpuid.py
@@ -47,8 +47,8 @@ def parse_definitions(state):
     """
     feat_regex = re.compile(
         r"^XEN_CPUFEATURE\(([A-Z0-9_]+),"
-        "\s+([\s\d]+\*[\s\d]+\+[\s\d]+)\)"
-        "\s+/\*([\w!]*) .*$")
+        r"\s+([\s\d]+\*[\s\d]+\+[\s\d]+)\)"
+        r"\s+/\*([\w!]*) .*$")
 
     word_regex = re.compile(
         r"^/\* .* word (\d*) \*/$")
-- 
2.44.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] xen/x86: Fix Syntax warning in gen-cpuid.py
  2024-04-26  4:07 [PATCH] xen/x86: Fix Syntax warning in gen-cpuid.py Jason Andryuk
@ 2024-04-26 19:07 ` Andrew Cooper
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Cooper @ 2024-04-26 19:07 UTC (permalink / raw
  To: Jason Andryuk, xen-devel; +Cc: Jan Beulich, Roger Pau Monné

On 26/04/2024 5:07 am, Jason Andryuk wrote:
> Python 3.12.2 warns:
>
> xen/tools/gen-cpuid.py:50: SyntaxWarning: invalid escape sequence '\s'
>   "\s+([\s\d]+\*[\s\d]+\+[\s\d]+)\)"
> xen/tools/gen-cpuid.py:51: SyntaxWarning: invalid escape sequence '\s'
>   "\s+/\*([\w!]*) .*$")
>
> Specify the strings as raw strings so '\s' is read as literal '\' + 's'.
> This avoids escaping all the '\'s in the strings.
>
> Signed-off-by: Jason Andryuk <jason.andryuk@amd.com>

That's something I didn't know about how python does string
concatenation.  I was expecting the whole string to be considered raw,
not just the first line.

Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>

I'll rebase my pending change altering the regex over this.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-04-26 19:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-26  4:07 [PATCH] xen/x86: Fix Syntax warning in gen-cpuid.py Jason Andryuk
2024-04-26 19:07 ` Andrew Cooper

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.