* [PATCH 0/1] tools, xen/scripts: clear out Python syntax warnings
@ 2024-12-14 16:09 Ariel Otilibili
2024-12-14 16:09 ` [PATCH 1/1] " Ariel Otilibili
2024-12-16 23:07 ` [PATCH v2 0/1] " Ariel Otilibili
0 siblings, 2 replies; 12+ messages in thread
From: Ariel Otilibili @ 2024-12-14 16:09 UTC (permalink / raw)
To: xen-devel; +Cc: Jan Beulich, nthony PERARD, Ariel Otilibili
Hello,
The series clears out Python syntax warnings. In all occurrences of the re methods,
```
$ git grep -Pn '[^\w_]re\.[a-z]+' | wc -l
69
```
Where it was needed, the strings have been quoted as raw.
Thank you,
Ariel Otilibili (1):
tools, xen/scripts: clear out Python syntax warnings
tools/misc/xensymoops | 4 ++--
tools/pygrub/src/GrubConf.py | 4 ++--
tools/pygrub/src/pygrub | 6 +++---
xen/scripts/xen_analysis/cppcheck_analysis.py | 4 ++--
4 files changed, 9 insertions(+), 9 deletions(-)
--
2.47.1
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/1] tools, xen/scripts: clear out Python syntax warnings
2024-12-14 16:09 [PATCH 0/1] tools, xen/scripts: clear out Python syntax warnings Ariel Otilibili
@ 2024-12-14 16:09 ` Ariel Otilibili
2024-12-16 11:34 ` Andrew Cooper
2024-12-16 23:07 ` [PATCH v2 0/1] " Ariel Otilibili
1 sibling, 1 reply; 12+ messages in thread
From: Ariel Otilibili @ 2024-12-14 16:09 UTC (permalink / raw)
To: xen-devel; +Cc: Jan Beulich, nthony PERARD, Ariel Otilibili, Luca Fancellu
* since 3.12 invalid escape sequences generate SyntaxWarning
* in the future, these invalid sequences will generate SyntaxError
* therefore changed syntax to raw string notation.
Link: https://docs.python.org/3/whatsnew/3.12.html#other-language-changes
Fixes: e45e8f69047 ("bitkeeper revision 1.803 (4056f51d2UjBnn9uwzC9Vu3LspnUCg)")
Fixes: d8f3a67bf98 ("pygrub: further improve grub2 support")
Fixes: dd03048708a ("xen/pygrub: grub2/grub.cfg from RHEL 7 has new commands in menuentry")
Fixes: d1b93ea2615 ("tools/pygrub: Make pygrub understand default entry in string format")
Fixes: 622e368758b ("Add ZFS libfsimage support patch")
Fixes: 02b26c02c7c ("xen/scripts: add cppcheck tool to the xen-analysis.py script")
Fixes: 56c0063f4e7 ("xen/misra: xen-analysis.py: Improve the cppcheck version check")
Cc: Anthony PERARD <anthony.perard@vates.tech>
Cc: Luca Fancellu <luca.fancellu@arm.com>
Signed-off-by: Ariel Otilibili <Ariel.Otilibili-Anieli@eurecom.fr>
---
tools/misc/xensymoops | 4 ++--
tools/pygrub/src/GrubConf.py | 4 ++--
tools/pygrub/src/pygrub | 6 +++---
xen/scripts/xen_analysis/cppcheck_analysis.py | 4 ++--
4 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/tools/misc/xensymoops b/tools/misc/xensymoops
index 835d187e90..bec75cae93 100755
--- a/tools/misc/xensymoops
+++ b/tools/misc/xensymoops
@@ -17,7 +17,7 @@ def read_oops():
stack_addrs is a dictionary mapping potential code addresses in the stack
to their order in the stack trace.
"""
- stackaddr_ptn = "\[([a-z,0-9]*)\]"
+ stackaddr_ptn = r"\[([a-z,0-9]*)\]"
stackaddr_re = re.compile(stackaddr_ptn)
eip_ptn = ".*EIP:.*<([a-z,0-9]*)>.*"
@@ -67,7 +67,7 @@ addr_ptn = "([a-z,0-9]*):"
addr_re = re.compile(addr_ptn)
# regexp to match the start of functions in the objdump
-func_ptn = "(.*<[\S]*>):"
+func_ptn = r"(.*<[\S]*>):"
func_re = re.compile(func_ptn)
func = "<No function>" # holds the name of the current function being scanned
diff --git a/tools/pygrub/src/GrubConf.py b/tools/pygrub/src/GrubConf.py
index 580c9628ca..7cd2bc9aeb 100644
--- a/tools/pygrub/src/GrubConf.py
+++ b/tools/pygrub/src/GrubConf.py
@@ -320,7 +320,7 @@ class GrubConfigFile(_GrubConfigFile):
def grub2_handle_set(arg):
(com,arg) = grub_split(arg,2)
com="set:" + com
- m = re.match("([\"\'])(.*)\\1", arg)
+ m = re.match(r"([\"\'])(.*)\\1", arg)
if m is not None:
arg=m.group(2)
return (com,arg)
@@ -402,7 +402,7 @@ class Grub2ConfigFile(_GrubConfigFile):
continue
# new image
- title_match = re.match('^menuentry ["\'](.*?)["\'] (.*){', l)
+ title_match = re.match(r'^menuentry ["\'](.*?)["\'] (.*){', l)
if title_match:
if img is not None:
raise RuntimeError("syntax error: cannot nest menuentry (%d %s)" % (len(img),img))
diff --git a/tools/pygrub/src/pygrub b/tools/pygrub/src/pygrub
index 9d51f96070..58b088d285 100755
--- a/tools/pygrub/src/pygrub
+++ b/tools/pygrub/src/pygrub
@@ -614,7 +614,7 @@ class Grub:
title = self.cf.default
while 1:
try:
- title = re.search('(\S)>(\S.+$)',title).group(2)
+ title = re.search(r'(\S)>(\S.+$)',title).group(2)
except AttributeError:
break
@@ -1039,7 +1039,7 @@ if __name__ == "__main__":
# if boot filesystem is set then pass to fsimage.open
bootfsargs = '"%s"' % incfg["args"]
- bootfsgroup = re.findall('zfs-bootfs=(.*?)[\s\,\"]', bootfsargs)
+ bootfsgroup = re.findall(r'zfs-bootfs=(.*?)[\s\,\"]', bootfsargs)
if bootfsgroup:
bootfsoptions = bootfsgroup[0]
else:
@@ -1104,7 +1104,7 @@ if __name__ == "__main__":
if chosencfg["args"]:
zfsinfo = xenfsimage.getbootstring(fs)
if zfsinfo is not None:
- e = re.compile("zfs-bootfs=[\w\-\.\:@/]+" )
+ e = re.compile(r"zfs-bootfs=[\w\-\.\:@/]+" )
(chosencfg["args"],count) = e.subn(zfsinfo, chosencfg["args"])
if count == 0:
chosencfg["args"] += " -B %s" % zfsinfo
diff --git a/xen/scripts/xen_analysis/cppcheck_analysis.py b/xen/scripts/xen_analysis/cppcheck_analysis.py
index 850335c998..ce7bda91b6 100644
--- a/xen/scripts/xen_analysis/cppcheck_analysis.py
+++ b/xen/scripts/xen_analysis/cppcheck_analysis.py
@@ -93,7 +93,7 @@ def __generate_suppression_list(out_file):
# start of a comment '/*'
comment_line_starts = re.match('^[ \t]*/\*.*$', line)
# Matches a line with text and the end of a comment '*/'
- comment_line_stops = re.match('^.*\*/$', line)
+ comment_line_stops = re.match(r'^.*\*/$', line)
if (not comment_section) and comment_line_starts:
comment_section = True
if (len(line.strip()) != 0) and (not comment_section):
@@ -157,7 +157,7 @@ def generate_cppcheck_deps():
"Error occured retrieving cppcheck version:\n{}\n\n{}"
)
- version_regex = re.search('^Cppcheck (\d+)\.(\d+)(?:\.\d+)?$',
+ version_regex = re.search(r'^Cppcheck (\d+)\.(\d+)(?:\.\d+)?$',
invoke_cppcheck, flags=re.M)
# Currently, only cppcheck version >= 2.7 is supported, but version 2.8 is
# known to be broken, please refer to docs/misra/cppcheck.txt
--
2.47.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 1/1] tools, xen/scripts: clear out Python syntax warnings
2024-12-14 16:09 ` [PATCH 1/1] " Ariel Otilibili
@ 2024-12-16 11:34 ` Andrew Cooper
2024-12-16 16:51 ` Ariel Otilibili-Anieli
0 siblings, 1 reply; 12+ messages in thread
From: Andrew Cooper @ 2024-12-16 11:34 UTC (permalink / raw)
To: Ariel Otilibili, xen-devel; +Cc: Jan Beulich, nthony PERARD, Luca Fancellu
On 14/12/2024 4:09 pm, Ariel Otilibili wrote:
> * since 3.12 invalid escape sequences generate SyntaxWarning
> * in the future, these invalid sequences will generate SyntaxError
> * therefore changed syntax to raw string notation.
>
> Link: https://docs.python.org/3/whatsnew/3.12.html#other-language-changes
> Fixes: e45e8f69047 ("bitkeeper revision 1.803 (4056f51d2UjBnn9uwzC9Vu3LspnUCg)")
> Fixes: d8f3a67bf98 ("pygrub: further improve grub2 support")
> Fixes: dd03048708a ("xen/pygrub: grub2/grub.cfg from RHEL 7 has new commands in menuentry")
> Fixes: d1b93ea2615 ("tools/pygrub: Make pygrub understand default entry in string format")
> Fixes: 622e368758b ("Add ZFS libfsimage support patch")
> Fixes: 02b26c02c7c ("xen/scripts: add cppcheck tool to the xen-analysis.py script")
> Fixes: 56c0063f4e7 ("xen/misra: xen-analysis.py: Improve the cppcheck version check")
>
> Cc: Anthony PERARD <anthony.perard@vates.tech>
> Cc: Luca Fancellu <luca.fancellu@arm.com>
> Signed-off-by: Ariel Otilibili <Ariel.Otilibili-Anieli@eurecom.fr>
> ---
> tools/misc/xensymoops | 4 ++--
> tools/pygrub/src/GrubConf.py | 4 ++--
> tools/pygrub/src/pygrub | 6 +++---
> xen/scripts/xen_analysis/cppcheck_analysis.py | 4 ++--
> 4 files changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/tools/misc/xensymoops b/tools/misc/xensymoops
> index 835d187e90..bec75cae93 100755
> --- a/tools/misc/xensymoops
> +++ b/tools/misc/xensymoops
> @@ -17,7 +17,7 @@ def read_oops():
> stack_addrs is a dictionary mapping potential code addresses in the stack
> to their order in the stack trace.
> """
> - stackaddr_ptn = "\[([a-z,0-9]*)\]"
> + stackaddr_ptn = r"\[([a-z,0-9]*)\]"
> stackaddr_re = re.compile(stackaddr_ptn)
>
> eip_ptn = ".*EIP:.*<([a-z,0-9]*)>.*"
Oh wow. I've not come across this script before, and it's not
referenced in the build system.
Also, it's hard-coded to 32bit Xen which was deleted in Xen 4.13 more
than a decade ago, and there are other errors in the regexes such as
including a comma in stackaddr_ptn
Worse however, it escaped the Py2->3 conversion and is still using raw
print statements.
I'll submit a patch deleting it entirely.
> diff --git a/tools/pygrub/src/GrubConf.py b/tools/pygrub/src/GrubConf.py
> index 580c9628ca..7cd2bc9aeb 100644
> --- a/tools/pygrub/src/GrubConf.py
> +++ b/tools/pygrub/src/GrubConf.py
> @@ -320,7 +320,7 @@ class GrubConfigFile(_GrubConfigFile):
> def grub2_handle_set(arg):
> (com,arg) = grub_split(arg,2)
> com="set:" + com
> - m = re.match("([\"\'])(.*)\\1", arg)
> + m = re.match(r"([\"\'])(.*)\\1", arg)
Doesn't this \\1 want to turn into just \1 now it's a raw string?
> diff --git a/tools/pygrub/src/pygrub b/tools/pygrub/src/pygrub
> index 9d51f96070..58b088d285 100755
> --- a/tools/pygrub/src/pygrub
> +++ b/tools/pygrub/src/pygrub
> @@ -1104,7 +1104,7 @@ if __name__ == "__main__":
> if chosencfg["args"]:
> zfsinfo = xenfsimage.getbootstring(fs)
> if zfsinfo is not None:
> - e = re.compile("zfs-bootfs=[\w\-\.\:@/]+" )
> + e = re.compile(r"zfs-bootfs=[\w\-\.\:@/]+" )
Related, this string looks dodgy. The \- is correct (I think, to not
have it interpreted as a range), but I'm pretty sure a literal . and :
don't need escaping inside a [], and the result here would be for a
literal \ to be included.
~Andrew
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/1] tools, xen/scripts: clear out Python syntax warnings
2024-12-16 11:34 ` Andrew Cooper
@ 2024-12-16 16:51 ` Ariel Otilibili-Anieli
0 siblings, 0 replies; 12+ messages in thread
From: Ariel Otilibili-Anieli @ 2024-12-16 16:51 UTC (permalink / raw)
To: Andrew Cooper; +Cc: xen-devel, Jan Beulich, Luca Fancellu, Anthony PERARD
On Monday, December 16, 2024 12:34 CET, Andrew Cooper <andrew.cooper3@citrix.com> wrote:
> On 14/12/2024 4:09 pm, Ariel Otilibili wrote:
> > * since 3.12 invalid escape sequences generate SyntaxWarning
> > * in the future, these invalid sequences will generate SyntaxError
> > * therefore changed syntax to raw string notation.
> >
> > Link: https://docs.python.org/3/whatsnew/3.12.html#other-language-changes
> > Fixes: e45e8f69047 ("bitkeeper revision 1.803 (4056f51d2UjBnn9uwzC9Vu3LspnUCg)")
> > Fixes: d8f3a67bf98 ("pygrub: further improve grub2 support")
> > Fixes: dd03048708a ("xen/pygrub: grub2/grub.cfg from RHEL 7 has new commands in menuentry")
> > Fixes: d1b93ea2615 ("tools/pygrub: Make pygrub understand default entry in string format")
> > Fixes: 622e368758b ("Add ZFS libfsimage support patch")
> > Fixes: 02b26c02c7c ("xen/scripts: add cppcheck tool to the xen-analysis.py script")
> > Fixes: 56c0063f4e7 ("xen/misra: xen-analysis.py: Improve the cppcheck version check")
> >
> > Cc: Anthony PERARD <anthony.perard@vates.tech>
> > Cc: Luca Fancellu <luca.fancellu@arm.com>
> > Signed-off-by: Ariel Otilibili <Ariel.Otilibili-Anieli@eurecom.fr>
> > ---
> > tools/misc/xensymoops | 4 ++--
> > tools/pygrub/src/GrubConf.py | 4 ++--
> > tools/pygrub/src/pygrub | 6 +++---
> > xen/scripts/xen_analysis/cppcheck_analysis.py | 4 ++--
> > 4 files changed, 9 insertions(+), 9 deletions(-)
> >
> > diff --git a/tools/misc/xensymoops b/tools/misc/xensymoops
> > index 835d187e90..bec75cae93 100755
> > --- a/tools/misc/xensymoops
> > +++ b/tools/misc/xensymoops
> > @@ -17,7 +17,7 @@ def read_oops():
> > stack_addrs is a dictionary mapping potential code addresses in the stack
> > to their order in the stack trace.
> > """
> > - stackaddr_ptn = "\[([a-z,0-9]*)\]"
> > + stackaddr_ptn = r"\[([a-z,0-9]*)\]"
> > stackaddr_re = re.compile(stackaddr_ptn)
> >
> > eip_ptn = ".*EIP:.*<([a-z,0-9]*)>.*"
>
> Oh wow. I've not come across this script before, and it's not
> referenced in the build system.
>
> Also, it's hard-coded to 32bit Xen which was deleted in Xen 4.13 more
> than a decade ago, and there are other errors in the regexes such as
> including a comma in stackaddr_ptn
>
> Worse however, it escaped the Py2->3 conversion and is still using raw
> print statements.
>
> I'll submit a patch deleting it entirely.
Acked-by: Ariel Otilibili-Anieli <Ariel.Otilibili-Anieli@eurecom.fr>
I'll send a new series, only on the subsequent feedback.
>
> > diff --git a/tools/pygrub/src/GrubConf.py b/tools/pygrub/src/GrubConf.py
> > index 580c9628ca..7cd2bc9aeb 100644
> > --- a/tools/pygrub/src/GrubConf.py
> > +++ b/tools/pygrub/src/GrubConf.py
> > @@ -320,7 +320,7 @@ class GrubConfigFile(_GrubConfigFile):
> > def grub2_handle_set(arg):
> > (com,arg) = grub_split(arg,2)
> > com="set:" + com
> > - m = re.match("([\"\'])(.*)\\1", arg)
> > + m = re.match(r"([\"\'])(.*)\\1", arg)
>
> Doesn't this \\1 want to turn into just \1 now it's a raw string?
Indeed; I'll do that.
>
> > diff --git a/tools/pygrub/src/pygrub b/tools/pygrub/src/pygrub
> > index 9d51f96070..58b088d285 100755
> > --- a/tools/pygrub/src/pygrub
> > +++ b/tools/pygrub/src/pygrub
> > @@ -1104,7 +1104,7 @@ if __name__ == "__main__":
> > if chosencfg["args"]:
> > zfsinfo = xenfsimage.getbootstring(fs)
> > if zfsinfo is not None:
> > - e = re.compile("zfs-bootfs=[\w\-\.\:@/]+" )
> > + e = re.compile(r"zfs-bootfs=[\w\-\.\:@/]+" )
>
> Related, this string looks dodgy. The \- is correct (I think, to not
> have it interpreted as a range), but I'm pretty sure a literal . and :
> don't need escaping inside a [], and the result here would be for a
> literal \ to be included.
>
To replace: \w\-\.\:@/
By: \w\-.:@/
Is this what you mean?
> ~Andrew
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v2 0/1] tools, xen/scripts: clear out Python syntax warnings
2024-12-14 16:09 [PATCH 0/1] tools, xen/scripts: clear out Python syntax warnings Ariel Otilibili
2024-12-14 16:09 ` [PATCH 1/1] " Ariel Otilibili
@ 2024-12-16 23:07 ` Ariel Otilibili
2024-12-16 23:07 ` [PATCH v2 1/1] " Ariel Otilibili
1 sibling, 1 reply; 12+ messages in thread
From: Ariel Otilibili @ 2024-12-16 23:07 UTC (permalink / raw)
To: xen-devel; +Cc: Jan Beulich, Anthony PERARD, Andrew Cooper, Ariel Otilibili
Hello,
The series clears out Python syntax warnings. In all occurrences of the re methods,
```
$ git grep -Pn '[^\w_]re\.[a-z]+' | wc -l
69
```
Where it was needed, the strings have been quoted as raw.
Thank you,
--
v2:
* tools/misc/xensymoops got removed (2e955d2554, "tools/misc: Drop xensymoops")
* refined regexes (https://lore.kernel.org/all/49497f8c-a2e4-49a1-aac0-96d704834f0f@citrix.com/)
Ariel Otilibili (1):
tools, xen/scripts: clear out Python syntax warnings
tools/pygrub/src/GrubConf.py | 4 ++--
tools/pygrub/src/pygrub | 6 +++---
xen/scripts/xen_analysis/cppcheck_analysis.py | 4 ++--
3 files changed, 7 insertions(+), 7 deletions(-)
--
2.47.1
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v2 1/1] tools, xen/scripts: clear out Python syntax warnings
2024-12-16 23:07 ` [PATCH v2 0/1] " Ariel Otilibili
@ 2024-12-16 23:07 ` Ariel Otilibili
2024-12-17 8:31 ` Luca Fancellu
2024-12-17 16:26 ` Andrew Cooper
0 siblings, 2 replies; 12+ messages in thread
From: Ariel Otilibili @ 2024-12-16 23:07 UTC (permalink / raw)
To: xen-devel
Cc: Jan Beulich, Anthony PERARD, Andrew Cooper, Ariel Otilibili,
Luca Fancellu
* since 3.12 invalid escape sequences generate SyntaxWarning
* in the future, these invalid sequences will generate SyntaxError
* therefore changed syntax to raw string notation.
Link: https://docs.python.org/3/whatsnew/3.12.html#other-language-changes
Fixes: d8f3a67bf98 ("pygrub: further improve grub2 support")
Fixes: dd03048708a ("xen/pygrub: grub2/grub.cfg from RHEL 7 has new commands in menuentry")
Fixes: d1b93ea2615 ("tools/pygrub: Make pygrub understand default entry in string format")
Fixes: 622e368758b ("Add ZFS libfsimage support patch")
Fixes: 02b26c02c7c ("xen/scripts: add cppcheck tool to the xen-analysis.py script")
Fixes: 56c0063f4e7 ("xen/misra: xen-analysis.py: Improve the cppcheck version check")
Cc: Anthony PERARD <anthony.perard@vates.tech>
Cc: Luca Fancellu <luca.fancellu@arm.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Ariel Otilibili <Ariel.Otilibili-Anieli@eurecom.fr>
---
tools/pygrub/src/GrubConf.py | 4 ++--
tools/pygrub/src/pygrub | 6 +++---
xen/scripts/xen_analysis/cppcheck_analysis.py | 4 ++--
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/tools/pygrub/src/GrubConf.py b/tools/pygrub/src/GrubConf.py
index 580c9628ca..904e7d5567 100644
--- a/tools/pygrub/src/GrubConf.py
+++ b/tools/pygrub/src/GrubConf.py
@@ -320,7 +320,7 @@ class GrubConfigFile(_GrubConfigFile):
def grub2_handle_set(arg):
(com,arg) = grub_split(arg,2)
com="set:" + com
- m = re.match("([\"\'])(.*)\\1", arg)
+ m = re.match(r"([\"\'])(.*)\1", arg)
if m is not None:
arg=m.group(2)
return (com,arg)
@@ -402,7 +402,7 @@ class Grub2ConfigFile(_GrubConfigFile):
continue
# new image
- title_match = re.match('^menuentry ["\'](.*?)["\'] (.*){', l)
+ title_match = re.match(r'^menuentry ["\'](.*?)["\'] (.*){', l)
if title_match:
if img is not None:
raise RuntimeError("syntax error: cannot nest menuentry (%d %s)" % (len(img),img))
diff --git a/tools/pygrub/src/pygrub b/tools/pygrub/src/pygrub
index 9d51f96070..e1657c494b 100755
--- a/tools/pygrub/src/pygrub
+++ b/tools/pygrub/src/pygrub
@@ -614,7 +614,7 @@ class Grub:
title = self.cf.default
while 1:
try:
- title = re.search('(\S)>(\S.+$)',title).group(2)
+ title = re.search(r'(\S)>(\S.+$)',title).group(2)
except AttributeError:
break
@@ -1039,7 +1039,7 @@ if __name__ == "__main__":
# if boot filesystem is set then pass to fsimage.open
bootfsargs = '"%s"' % incfg["args"]
- bootfsgroup = re.findall('zfs-bootfs=(.*?)[\s\,\"]', bootfsargs)
+ bootfsgroup = re.findall(r'zfs-bootfs=(.*?)[\s\,\"]', bootfsargs)
if bootfsgroup:
bootfsoptions = bootfsgroup[0]
else:
@@ -1104,7 +1104,7 @@ if __name__ == "__main__":
if chosencfg["args"]:
zfsinfo = xenfsimage.getbootstring(fs)
if zfsinfo is not None:
- e = re.compile("zfs-bootfs=[\w\-\.\:@/]+" )
+ e = re.compile(r"zfs-bootfs=[\w\-.:@/]+" )
(chosencfg["args"],count) = e.subn(zfsinfo, chosencfg["args"])
if count == 0:
chosencfg["args"] += " -B %s" % zfsinfo
diff --git a/xen/scripts/xen_analysis/cppcheck_analysis.py b/xen/scripts/xen_analysis/cppcheck_analysis.py
index 850335c998..ce7bda91b6 100644
--- a/xen/scripts/xen_analysis/cppcheck_analysis.py
+++ b/xen/scripts/xen_analysis/cppcheck_analysis.py
@@ -93,7 +93,7 @@ def __generate_suppression_list(out_file):
# start of a comment '/*'
comment_line_starts = re.match('^[ \t]*/\*.*$', line)
# Matches a line with text and the end of a comment '*/'
- comment_line_stops = re.match('^.*\*/$', line)
+ comment_line_stops = re.match(r'^.*\*/$', line)
if (not comment_section) and comment_line_starts:
comment_section = True
if (len(line.strip()) != 0) and (not comment_section):
@@ -157,7 +157,7 @@ def generate_cppcheck_deps():
"Error occured retrieving cppcheck version:\n{}\n\n{}"
)
- version_regex = re.search('^Cppcheck (\d+)\.(\d+)(?:\.\d+)?$',
+ version_regex = re.search(r'^Cppcheck (\d+)\.(\d+)(?:\.\d+)?$',
invoke_cppcheck, flags=re.M)
# Currently, only cppcheck version >= 2.7 is supported, but version 2.8 is
# known to be broken, please refer to docs/misra/cppcheck.txt
--
2.47.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v2 1/1] tools, xen/scripts: clear out Python syntax warnings
2024-12-16 23:07 ` [PATCH v2 1/1] " Ariel Otilibili
@ 2024-12-17 8:31 ` Luca Fancellu
2024-12-17 13:26 ` Ariel Otilibili-Anieli
2024-12-17 16:26 ` Andrew Cooper
1 sibling, 1 reply; 12+ messages in thread
From: Luca Fancellu @ 2024-12-17 8:31 UTC (permalink / raw)
To: Ariel Otilibili
Cc: xen-devel@lists.xenproject.org, Jan Beulich, Anthony PERARD,
Andrew Cooper
Hi Ariel,
> On 16 Dec 2024, at 23:07, Ariel Otilibili <Ariel.Otilibili-Anieli@eurecom.fr> wrote:
>
> * since 3.12 invalid escape sequences generate SyntaxWarning
> * in the future, these invalid sequences will generate SyntaxError
> * therefore changed syntax to raw string notation.
>
> Link: https://docs.python.org/3/whatsnew/3.12.html#other-language-changes
> Fixes: d8f3a67bf98 ("pygrub: further improve grub2 support")
> Fixes: dd03048708a ("xen/pygrub: grub2/grub.cfg from RHEL 7 has new commands in menuentry")
> Fixes: d1b93ea2615 ("tools/pygrub: Make pygrub understand default entry in string format")
> Fixes: 622e368758b ("Add ZFS libfsimage support patch")
> Fixes: 02b26c02c7c ("xen/scripts: add cppcheck tool to the xen-analysis.py script")
> Fixes: 56c0063f4e7 ("xen/misra: xen-analysis.py: Improve the cppcheck version check")
>
> Cc: Anthony PERARD <anthony.perard@vates.tech>
> Cc: Luca Fancellu <luca.fancellu@arm.com>
> Cc: Andrew Cooper <andrew.cooper3@citrix.com>
> Signed-off-by: Ariel Otilibili <Ariel.Otilibili-Anieli@eurecom.fr>
For the xen_analysis tool:
Reviewed-by: Luca Fancellu <luca.fancellu@arm.com>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2 1/1] tools, xen/scripts: clear out Python syntax warnings
2024-12-17 8:31 ` Luca Fancellu
@ 2024-12-17 13:26 ` Ariel Otilibili-Anieli
0 siblings, 0 replies; 12+ messages in thread
From: Ariel Otilibili-Anieli @ 2024-12-17 13:26 UTC (permalink / raw)
To: Luca Fancellu
Cc: xen-devel@lists.xenproject.org, Jan Beulich, Anthony PERARD,
Andrew Cooper
On Tuesday, December 17, 2024 09:31 CET, Luca Fancellu <Luca.Fancellu@arm.com> wrote:
> Hi Ariel,
>
> > On 16 Dec 2024, at 23:07, Ariel Otilibili <Ariel.Otilibili-Anieli@eurecom.fr> wrote:
> >
> > * since 3.12 invalid escape sequences generate SyntaxWarning
> > * in the future, these invalid sequences will generate SyntaxError
> > * therefore changed syntax to raw string notation.
> >
> > Link: https://docs.python.org/3/whatsnew/3.12.html#other-language-changes
> > Fixes: d8f3a67bf98 ("pygrub: further improve grub2 support")
> > Fixes: dd03048708a ("xen/pygrub: grub2/grub.cfg from RHEL 7 has new commands in menuentry")
> > Fixes: d1b93ea2615 ("tools/pygrub: Make pygrub understand default entry in string format")
> > Fixes: 622e368758b ("Add ZFS libfsimage support patch")
> > Fixes: 02b26c02c7c ("xen/scripts: add cppcheck tool to the xen-analysis.py script")
> > Fixes: 56c0063f4e7 ("xen/misra: xen-analysis.py: Improve the cppcheck version check")
> >
> > Cc: Anthony PERARD <anthony.perard@vates.tech>
> > Cc: Luca Fancellu <luca.fancellu@arm.com>
> > Cc: Andrew Cooper <andrew.cooper3@citrix.com>
> > Signed-off-by: Ariel Otilibili <Ariel.Otilibili-Anieli@eurecom.fr>
>
> For the xen_analysis tool:
>
> Reviewed-by: Luca Fancellu <luca.fancellu@arm.com>
Awesome, Luca; thanks for review.
I am looking forward a feedback on the other hunks.
Ariel
>
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2 1/1] tools, xen/scripts: clear out Python syntax warnings
2024-12-16 23:07 ` [PATCH v2 1/1] " Ariel Otilibili
2024-12-17 8:31 ` Luca Fancellu
@ 2024-12-17 16:26 ` Andrew Cooper
2024-12-17 17:13 ` Ariel Otilibili-Anieli
1 sibling, 1 reply; 12+ messages in thread
From: Andrew Cooper @ 2024-12-17 16:26 UTC (permalink / raw)
To: Ariel Otilibili, xen-devel; +Cc: Jan Beulich, Anthony PERARD, Luca Fancellu
On 16/12/2024 11:07 pm, Ariel Otilibili wrote:
> * since 3.12 invalid escape sequences generate SyntaxWarning
> * in the future, these invalid sequences will generate SyntaxError
> * therefore changed syntax to raw string notation.
>
> Link: https://docs.python.org/3/whatsnew/3.12.html#other-language-changes
> Fixes: d8f3a67bf98 ("pygrub: further improve grub2 support")
> Fixes: dd03048708a ("xen/pygrub: grub2/grub.cfg from RHEL 7 has new commands in menuentry")
> Fixes: d1b93ea2615 ("tools/pygrub: Make pygrub understand default entry in string format")
> Fixes: 622e368758b ("Add ZFS libfsimage support patch")
> Fixes: 02b26c02c7c ("xen/scripts: add cppcheck tool to the xen-analysis.py script")
> Fixes: 56c0063f4e7 ("xen/misra: xen-analysis.py: Improve the cppcheck version check")
>
> Cc: Anthony PERARD <anthony.perard@vates.tech>
> Cc: Luca Fancellu <luca.fancellu@arm.com>
> Cc: Andrew Cooper <andrew.cooper3@citrix.com>
> Signed-off-by: Ariel Otilibili <Ariel.Otilibili-Anieli@eurecom.fr>
Having poked about a bit more, this is all a big mess, but these do now
work with Py3.12.
leading \ for non-special characters are ignored in [], which is why ...
> ---
> tools/pygrub/src/GrubConf.py | 4 ++--
> tools/pygrub/src/pygrub | 6 +++---
> xen/scripts/xen_analysis/cppcheck_analysis.py | 4 ++--
> 3 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/tools/pygrub/src/GrubConf.py b/tools/pygrub/src/GrubConf.py
> index 580c9628ca..904e7d5567 100644
> --- a/tools/pygrub/src/GrubConf.py
> +++ b/tools/pygrub/src/GrubConf.py
> @@ -320,7 +320,7 @@ class GrubConfigFile(_GrubConfigFile):
> def grub2_handle_set(arg):
> (com,arg) = grub_split(arg,2)
> com="set:" + com
> - m = re.match("([\"\'])(.*)\\1", arg)
> + m = re.match(r"([\"\'])(.*)\1", arg)
... the \' works here.
Anyway, I've checked the others and they seem to work, so I suggest
taking this roughly this form.
Some notes about the commit message. The subject ought to be:
tools: Fix syntax warnings with Python 3.12
The text should be a regular paragraph, rather than bullet points like this.
I can fix this all on commit if you're happy.
~Andrew
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2 1/1] tools, xen/scripts: clear out Python syntax warnings
2024-12-17 16:26 ` Andrew Cooper
@ 2024-12-17 17:13 ` Ariel Otilibili-Anieli
2024-12-18 14:21 ` Andrew Cooper
0 siblings, 1 reply; 12+ messages in thread
From: Ariel Otilibili-Anieli @ 2024-12-17 17:13 UTC (permalink / raw)
To: Andrew Cooper; +Cc: xen-devel, Jan Beulich, Anthony PERARD, Luca Fancellu
On Tuesday, December 17, 2024 17:26 CET, Andrew Cooper <andrew.cooper3@citrix.com> wrote:
> On 16/12/2024 11:07 pm, Ariel Otilibili wrote:
> > * since 3.12 invalid escape sequences generate SyntaxWarning
> > * in the future, these invalid sequences will generate SyntaxError
> > * therefore changed syntax to raw string notation.
> >
> > Link: https://docs.python.org/3/whatsnew/3.12.html#other-language-changes
> > Fixes: d8f3a67bf98 ("pygrub: further improve grub2 support")
> > Fixes: dd03048708a ("xen/pygrub: grub2/grub.cfg from RHEL 7 has new commands in menuentry")
> > Fixes: d1b93ea2615 ("tools/pygrub: Make pygrub understand default entry in string format")
> > Fixes: 622e368758b ("Add ZFS libfsimage support patch")
> > Fixes: 02b26c02c7c ("xen/scripts: add cppcheck tool to the xen-analysis.py script")
> > Fixes: 56c0063f4e7 ("xen/misra: xen-analysis.py: Improve the cppcheck version check")
> >
> > Cc: Anthony PERARD <anthony.perard@vates.tech>
> > Cc: Luca Fancellu <luca.fancellu@arm.com>
> > Cc: Andrew Cooper <andrew.cooper3@citrix.com>
> > Signed-off-by: Ariel Otilibili <Ariel.Otilibili-Anieli@eurecom.fr>
>
> Having poked about a bit more, this is all a big mess, but these do now
> work with Py3.12.
>
> leading \ for non-special characters are ignored in [], which is why ...
>
> > ---
> > tools/pygrub/src/GrubConf.py | 4 ++--
> > tools/pygrub/src/pygrub | 6 +++---
> > xen/scripts/xen_analysis/cppcheck_analysis.py | 4 ++--
> > 3 files changed, 7 insertions(+), 7 deletions(-)
> >
> > diff --git a/tools/pygrub/src/GrubConf.py b/tools/pygrub/src/GrubConf.py
> > index 580c9628ca..904e7d5567 100644
> > --- a/tools/pygrub/src/GrubConf.py
> > +++ b/tools/pygrub/src/GrubConf.py
> > @@ -320,7 +320,7 @@ class GrubConfigFile(_GrubConfigFile):
> > def grub2_handle_set(arg):
> > (com,arg) = grub_split(arg,2)
> > com="set:" + com
> > - m = re.match("([\"\'])(.*)\\1", arg)
> > + m = re.match(r"([\"\'])(.*)\1", arg)
>
> ... the \' works here.
>
> Anyway, I've checked the others and they seem to work, so I suggest
> taking this roughly this form.
>
> Some notes about the commit message. The subject ought to be:
>
> tools: Fix syntax warnings with Python 3.12
>
> The text should be a regular paragraph, rather than bullet points like this.
>
> I can fix this all on commit if you're happy.
Thanks for the feedback, Andrew; I'm happy with your changes.
>
> ~Andrew
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2 1/1] tools, xen/scripts: clear out Python syntax warnings
2024-12-17 17:13 ` Ariel Otilibili-Anieli
@ 2024-12-18 14:21 ` Andrew Cooper
2024-12-18 15:20 ` Ariel Otilibili-Anieli
0 siblings, 1 reply; 12+ messages in thread
From: Andrew Cooper @ 2024-12-18 14:21 UTC (permalink / raw)
To: Ariel Otilibili-Anieli
Cc: xen-devel, Jan Beulich, Anthony PERARD, Luca Fancellu
On 17/12/2024 5:13 pm, Ariel Otilibili-Anieli wrote:
> On Tuesday, December 17, 2024 17:26 CET, Andrew Cooper <andrew.cooper3@citrix.com> wrote:
>
>> On 16/12/2024 11:07 pm, Ariel Otilibili wrote:
>>> * since 3.12 invalid escape sequences generate SyntaxWarning
>>> * in the future, these invalid sequences will generate SyntaxError
>>> * therefore changed syntax to raw string notation.
>>>
>>> Link: https://docs.python.org/3/whatsnew/3.12.html#other-language-changes
>>> Fixes: d8f3a67bf98 ("pygrub: further improve grub2 support")
>>> Fixes: dd03048708a ("xen/pygrub: grub2/grub.cfg from RHEL 7 has new commands in menuentry")
>>> Fixes: d1b93ea2615 ("tools/pygrub: Make pygrub understand default entry in string format")
>>> Fixes: 622e368758b ("Add ZFS libfsimage support patch")
>>> Fixes: 02b26c02c7c ("xen/scripts: add cppcheck tool to the xen-analysis.py script")
>>> Fixes: 56c0063f4e7 ("xen/misra: xen-analysis.py: Improve the cppcheck version check")
>>>
>>> Cc: Anthony PERARD <anthony.perard@vates.tech>
>>> Cc: Luca Fancellu <luca.fancellu@arm.com>
>>> Cc: Andrew Cooper <andrew.cooper3@citrix.com>
>>> Signed-off-by: Ariel Otilibili <Ariel.Otilibili-Anieli@eurecom.fr>
>> Having poked about a bit more, this is all a big mess, but these do now
>> work with Py3.12.
>>
>> leading \ for non-special characters are ignored in [], which is why ...
>>
>>> ---
>>> tools/pygrub/src/GrubConf.py | 4 ++--
>>> tools/pygrub/src/pygrub | 6 +++---
>>> xen/scripts/xen_analysis/cppcheck_analysis.py | 4 ++--
>>> 3 files changed, 7 insertions(+), 7 deletions(-)
>>>
>>> diff --git a/tools/pygrub/src/GrubConf.py b/tools/pygrub/src/GrubConf.py
>>> index 580c9628ca..904e7d5567 100644
>>> --- a/tools/pygrub/src/GrubConf.py
>>> +++ b/tools/pygrub/src/GrubConf.py
>>> @@ -320,7 +320,7 @@ class GrubConfigFile(_GrubConfigFile):
>>> def grub2_handle_set(arg):
>>> (com,arg) = grub_split(arg,2)
>>> com="set:" + com
>>> - m = re.match("([\"\'])(.*)\\1", arg)
>>> + m = re.match(r"([\"\'])(.*)\1", arg)
>> ... the \' works here.
>>
>> Anyway, I've checked the others and they seem to work, so I suggest
>> taking this roughly this form.
>>
>> Some notes about the commit message. The subject ought to be:
>>
>> tools: Fix syntax warnings with Python 3.12
>>
>> The text should be a regular paragraph, rather than bullet points like this.
>>
>> I can fix this all on commit if you're happy.
> Thanks for the feedback, Andrew; I'm happy with your changes.
And committed.
https://xenbits.xen.org/gitweb/?p=xen.git;a=commitdiff;h=826a9eb072d449cb777d71f52923e6f5f20cefbe
Thankyou for your patch.
~Andrew
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2 1/1] tools, xen/scripts: clear out Python syntax warnings
2024-12-18 14:21 ` Andrew Cooper
@ 2024-12-18 15:20 ` Ariel Otilibili-Anieli
0 siblings, 0 replies; 12+ messages in thread
From: Ariel Otilibili-Anieli @ 2024-12-18 15:20 UTC (permalink / raw)
To: Andrew Cooper; +Cc: xen-devel, Jan Beulich, Anthony PERARD, Luca Fancellu
On Wednesday, December 18, 2024 15:21 CET, Andrew Cooper <andrew.cooper3@citrix.com> wrote:
> On 17/12/2024 5:13 pm, Ariel Otilibili-Anieli wrote:
> > On Tuesday, December 17, 2024 17:26 CET, Andrew Cooper <andrew.cooper3@citrix.com> wrote:
> >
> >> On 16/12/2024 11:07 pm, Ariel Otilibili wrote:
> >>> * since 3.12 invalid escape sequences generate SyntaxWarning
> >>> * in the future, these invalid sequences will generate SyntaxError
> >>> * therefore changed syntax to raw string notation.
> >>>
> >>> Link: https://docs.python.org/3/whatsnew/3.12.html#other-language-changes
> >>> Fixes: d8f3a67bf98 ("pygrub: further improve grub2 support")
> >>> Fixes: dd03048708a ("xen/pygrub: grub2/grub.cfg from RHEL 7 has new commands in menuentry")
> >>> Fixes: d1b93ea2615 ("tools/pygrub: Make pygrub understand default entry in string format")
> >>> Fixes: 622e368758b ("Add ZFS libfsimage support patch")
> >>> Fixes: 02b26c02c7c ("xen/scripts: add cppcheck tool to the xen-analysis.py script")
> >>> Fixes: 56c0063f4e7 ("xen/misra: xen-analysis.py: Improve the cppcheck version check")
> >>>
> >>> Cc: Anthony PERARD <anthony.perard@vates.tech>
> >>> Cc: Luca Fancellu <luca.fancellu@arm.com>
> >>> Cc: Andrew Cooper <andrew.cooper3@citrix.com>
> >>> Signed-off-by: Ariel Otilibili <Ariel.Otilibili-Anieli@eurecom.fr>
> >> Having poked about a bit more, this is all a big mess, but these do now
> >> work with Py3.12.
> >>
> >> leading \ for non-special characters are ignored in [], which is why ...
> >>
> >>> ---
> >>> tools/pygrub/src/GrubConf.py | 4 ++--
> >>> tools/pygrub/src/pygrub | 6 +++---
> >>> xen/scripts/xen_analysis/cppcheck_analysis.py | 4 ++--
> >>> 3 files changed, 7 insertions(+), 7 deletions(-)
> >>>
> >>> diff --git a/tools/pygrub/src/GrubConf.py b/tools/pygrub/src/GrubConf.py
> >>> index 580c9628ca..904e7d5567 100644
> >>> --- a/tools/pygrub/src/GrubConf.py
> >>> +++ b/tools/pygrub/src/GrubConf.py
> >>> @@ -320,7 +320,7 @@ class GrubConfigFile(_GrubConfigFile):
> >>> def grub2_handle_set(arg):
> >>> (com,arg) = grub_split(arg,2)
> >>> com="set:" + com
> >>> - m = re.match("([\"\'])(.*)\\1", arg)
> >>> + m = re.match(r"([\"\'])(.*)\1", arg)
> >> ... the \' works here.
> >>
> >> Anyway, I've checked the others and they seem to work, so I suggest
> >> taking this roughly this form.
> >>
> >> Some notes about the commit message. The subject ought to be:
> >>
> >> tools: Fix syntax warnings with Python 3.12
> >>
> >> The text should be a regular paragraph, rather than bullet points like this.
> >>
> >> I can fix this all on commit if you're happy.
> > Thanks for the feedback, Andrew; I'm happy with your changes.
>
> And committed.
Awesome, Andrew! Thanks to you!
>
> https://xenbits.xen.org/gitweb/?p=xen.git;a=commitdiff;h=826a9eb072d449cb777d71f52923e6f5f20cefbe
>
> Thankyou for your patch.
>
> ~Andrew
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2024-12-18 15:20 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-14 16:09 [PATCH 0/1] tools, xen/scripts: clear out Python syntax warnings Ariel Otilibili
2024-12-14 16:09 ` [PATCH 1/1] " Ariel Otilibili
2024-12-16 11:34 ` Andrew Cooper
2024-12-16 16:51 ` Ariel Otilibili-Anieli
2024-12-16 23:07 ` [PATCH v2 0/1] " Ariel Otilibili
2024-12-16 23:07 ` [PATCH v2 1/1] " Ariel Otilibili
2024-12-17 8:31 ` Luca Fancellu
2024-12-17 13:26 ` Ariel Otilibili-Anieli
2024-12-17 16:26 ` Andrew Cooper
2024-12-17 17:13 ` Ariel Otilibili-Anieli
2024-12-18 14:21 ` Andrew Cooper
2024-12-18 15:20 ` Ariel Otilibili-Anieli
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.