[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAEf4BzbO=R-=4a2s8OF0Vhs+L4g+z0bwLm4q56eVRoWr6m5Zrw@mail.gmail.com>
Date: Fri, 10 Jan 2025 16:23:26 -0800
From: Andrii Nakryiko <andrii.nakryiko@...il.com>
To: Ariel Otilibili-Anieli <Ariel.Otilibili-Anieli@...ecom.fr>
Cc: Quentin Monnet <qmo@...n.net>, bpf@...r.kernel.org, Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>, Andrii Nakryiko <andrii@...nel.org>, Shuah Khan <shuah@...nel.org>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/1] selftests/bpf: clear out Python syntax warnings
On Fri, Dec 20, 2024 at 8:28 AM Ariel Otilibili-Anieli
<Ariel.Otilibili-Anieli@...ecom.fr> wrote:
>
> On Friday, December 20, 2024 17:24 CET, Quentin Monnet <qmo@...n.net> wrote:
>
> > 2024-12-11 22:57 UTC+0100 ~ Ariel Otilibili
> > <ariel.otilibili-anieli@...ecom.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@...nel.org>
> > > CC: Daniel Borkmann <daniel@...earbox.net>
> > > CC: Andrii Nakryiko <andrii@...nel.org>
> > > CC: Shuah Khan <shuah@...nel.org>
> > > Signed-off-by: Ariel Otilibili <ariel.otilibili-anieli@...ecom.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@...nel.org>
> > Reviewed-by: Quentin Monnet <qmo@...nel.org>
>
> Awesome, Quentin! Thanks for the feedback!
Seems like this was never applied, right? Ariel, can you please rebase
on latest bpf-next, add Quentin's tested-by and reviewed-by and
resend, so BPF CI can do another run on it? Thanks.
> >
> >
> > [0] https://docs.python.org/3.12/whatsnew/3.12.html#other-language-changes
> > [1] https://github.com/python/cpython/issues/98401
>
Powered by blists - more mailing lists