From: "Ariel Otilibili-Anieli" <Ariel.Otilibili-Anieli@eurecom.fr>
To: "Quentin Monnet" <qmo@qmon.net>
Cc: bpf@vger.kernel.org, "Alexei Starovoitov" <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Andrii Nakryiko" <andrii@kernel.org>,
"Shuah Khan" <shuah@kernel.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] selftests/bpf: clear out Python syntax warnings
Date: Fri, 20 Dec 2024 17:28:36 +0100 [thread overview]
Message-ID: <2f7a83-67659b00-a301-5cf12280@99585095> (raw)
In-Reply-To: <26180f2e-1ef7-45de-8e9e-f08a4e6a6d36@qmon.net>
On Friday, December 20, 2024 17:24 CET, Quentin Monnet <qmo@qmon.net> wrote:
> 2024-12-11 22:57 UTC+0100 ~ Ariel Otilibili
> <ariel.otilibili-anieli@eurecom.fr>
> > Invalid escape sequences are used, and produced syntax warnings:
> >
> > ```
> > $ test_bpftool_synctypes.py
> > test_bpftool_synctypes.py:69: SyntaxWarning: invalid escape sequence '\['
> > self.start_marker = re.compile(f'(static )?const bool {self.array_name}\[.*\] = {{\n')
> > test_bpftool_synctypes.py:83: SyntaxWarning: invalid escape sequence '\['
> > pattern = re.compile('\[(BPF_\w*)\]\s*= (true|false),?$')
> > test_bpftool_synctypes.py:181: SyntaxWarning: invalid escape sequence '\s'
> > pattern = re.compile('^\s*(BPF_\w+),?(\s+/\*.*\*/)?$')
> > test_bpftool_synctypes.py:229: SyntaxWarning: invalid escape sequence '\*'
> > start_marker = re.compile(f'\*{block_name}\* := {{')
> > test_bpftool_synctypes.py:229: SyntaxWarning: invalid escape sequence '\*'
> > start_marker = re.compile(f'\*{block_name}\* := {{')
> > test_bpftool_synctypes.py:230: SyntaxWarning: invalid escape sequence '\*'
> > pattern = re.compile('\*\*([\w/-]+)\*\*')
> > test_bpftool_synctypes.py:248: SyntaxWarning: invalid escape sequence '\s'
> > start_marker = re.compile(f'"\s*{block_name} := {{')
> > test_bpftool_synctypes.py:249: SyntaxWarning: invalid escape sequence '\w'
> > pattern = re.compile('([\w/]+) [|}]')
> > test_bpftool_synctypes.py:267: SyntaxWarning: invalid escape sequence '\s'
> > start_marker = re.compile(f'"\s*{macro}\s*" [|}}]')
> > test_bpftool_synctypes.py:267: SyntaxWarning: invalid escape sequence '\s'
> > start_marker = re.compile(f'"\s*{macro}\s*" [|}}]')
> > test_bpftool_synctypes.py:268: SyntaxWarning: invalid escape sequence '\w'
> > pattern = re.compile('([\w-]+) ?(?:\||}[ }\]])')
> > test_bpftool_synctypes.py:287: SyntaxWarning: invalid escape sequence '\w'
> > pattern = re.compile('(?:.*=\')?([\w/]+)')
> > test_bpftool_synctypes.py:319: SyntaxWarning: invalid escape sequence '\w'
> > pattern = re.compile('([\w-]+) ?(?:\||}[ }\]"])')
> > test_bpftool_synctypes.py:341: SyntaxWarning: invalid escape sequence '\|'
> > start_marker = re.compile('\|COMMON_OPTIONS\| replace:: {')
> > test_bpftool_synctypes.py:342: SyntaxWarning: invalid escape sequence '\*'
> > pattern = re.compile('\*\*([\w/-]+)\*\*')
> > ```
> >
> > Escaping them clears out the warnings.
> >
> > ```
> > $ tools/testing/selftests/bpf/test_bpftool_synctypes.py; echo $?
> > 0
> > ```
> >
> > Link: https://docs.python.org/fr/3/library/re.html
>
>
> En version anglaise : https://docs.python.org/3/library/re.html
Merci!
>
>
> > CC: Alexei Starovoitov <ast@kernel.org>
> > CC: Daniel Borkmann <daniel@iogearbox.net>
> > CC: Andrii Nakryiko <andrii@kernel.org>
> > CC: Shuah Khan <shuah@kernel.org>
> > Signed-off-by: Ariel Otilibili <ariel.otilibili-anieli@eurecom.fr>
>
> Right, this seems to be a change in Python 3.12 [0][1]:
>
> 'A backslash-character pair that is not a valid escape sequence now
> generates a SyntaxWarning, instead of DeprecationWarning. For example,
> re.compile("\d+\.\d+") now emits a SyntaxWarning ("\d" is an invalid
> escape sequence, use raw strings for regular expression:
> re.compile(r"\d+\.\d+")).'
>
> although I can't remember seeing any DeprecationWarning before.
>
> Anyway, the fix makes sense, and does address the warnings. Thank you
> for this!
>
> Tested-by: Quentin Monnet <qmo@kernel.org>
> Reviewed-by: Quentin Monnet <qmo@kernel.org>
Awesome, Quentin! Thanks for the feedback!
>
>
> [0] https://docs.python.org/3.12/whatsnew/3.12.html#other-language-changes
> [1] https://github.com/python/cpython/issues/98401
next prev parent reply other threads:[~2024-12-20 16:28 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-11 21:57 [PATCH 0/1] clear out Python syntax warnings Ariel Otilibili
2024-12-11 21:57 ` [PATCH 1/1] selftests/bpf: " Ariel Otilibili
2024-12-20 16:24 ` Quentin Monnet
2024-12-20 16:28 ` Ariel Otilibili-Anieli [this message]
2025-01-11 0:23 ` Andrii Nakryiko
2025-01-11 0:31 ` Ariel Otilibili-Anieli
2024-12-17 21:10 ` [PING] " Ariel Otilibili-Anieli
2024-12-20 17:00 ` [PATCH 0/1] " patchwork-bot+netdevbpf
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=2f7a83-67659b00-a301-5cf12280@99585095 \
--to=ariel.otilibili-anieli@eurecom.fr \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=linux-kernel@vger.kernel.org \
--cc=qmo@qmon.net \
--cc=shuah@kernel.org \
/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