From: Ian Abbott <abbotti@mev.co.uk>
To: Ilyas N <desobei@outlook.com>,
H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] comedi: ni_routing: fix SyntaxWarning in convert_csv_to_c.py
Date: Fri, 20 Nov 2026 09:44:49 +0000 [thread overview]
Message-ID: <cd79cc38-c094-498b-b5d8-4cc2f01d1c0d@mev.co.uk> (raw)
In-Reply-To: <PH7PR19MB66586FC98045CEA8D5067BDCAF792@PH7PR19MB6658.namprd19.prod.outlook.com>
On 2026-11-19 21:31, Ilyas N wrote:
> convert_csv_to_c.py validates register values against the regex
> '[VIU]\([^)]*\)', written as a plain string literal. "\(" and "\)" are
> not valid Python escape sequences, so with Python 3.12 and later every
> run of the script (e.g. "make c-files") prints:
>
> convert_csv_to_c.py:47: SyntaxWarning: "\(" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\\("? A raw string is also an option.
>
> Python currently keeps unrecognized escapes verbatim, so the regex still
> works, but the script will stop compiling once this warning becomes an
> error.
>
> Use a raw string. The resulting string is identical, so there is no
> functional change.
>
> The problem was found by compiling all in-tree Python files with Python
> 3.14 and SyntaxWarning promoted to an error. The search and this patch
> were done with the help of an AI coding assistant (Claude Opus 5.5).
> Tested by checking that the script now compiles cleanly with warnings
> as errors, that its compiled bytecode, constants and names are
> unchanged, and that the regex still accepts all 95 register values used
> in the ni_route_values tables.
>
> Signed-off-by: Ilyas N <desobei@outlook.com>
> ---
> v2: Use my real name in From: and Signed-off-by:, as Greg's patch bot
> asked. No code changes.
>
> v1: https://lore.kernel.org/all/PH7PR19MB66587C2BE5E8E94F693B4F14AF7A2@PH7PR19MB6658.namprd19.prod.outlook.com/
>
> drivers/comedi/drivers/ni_routing/tools/convert_csv_to_c.py | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/comedi/drivers/ni_routing/tools/convert_csv_to_c.py b/drivers/comedi/drivers/ni_routing/tools/convert_csv_to_c.py
> index 90378fb50580..d19101fc2a94 100755
> --- a/drivers/comedi/drivers/ni_routing/tools/convert_csv_to_c.py
> +++ b/drivers/comedi/drivers/ni_routing/tools/convert_csv_to_c.py
> @@ -44,7 +44,7 @@ def routedict_to_structinit_single(name, D, return_name=False):
>
> lines.append('\t\t[B({})] = {{'.format(D0_sig))
> for D1_sig, value in D1:
> - if not re.match('[VIU]\([^)]*\)', value):
> + if not re.match(r'[VIU]\([^)]*\)', value):
> sys.stderr.write('Invalid register format: {}\n'.format(repr(value)))
> sys.stderr.write(
> 'Register values should be formatted with V(),I(),or U()\n')
Thanks for the fix!
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
--
-=( Ian Abbott <abbotti@mev.co.uk> || MEV Ltd. is a company )=-
-=( registered in England & Wales. Regd. number: 02862268. )=-
-=( Regd. addr.: S11 & 12 Building 67, Europa Business Park, )=-
-=( Bird Hall Lane, STOCKPORT, SK3 0XA, UK. || www.mev.co.uk )=-
prev parent reply other threads:[~2026-11-20 9:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 21:31 Ilyas N
2026-11-20 9:44 ` Ian Abbott [this message]
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=cd79cc38-c094-498b-b5d8-4cc2f01d1c0d@mev.co.uk \
--to=abbotti@mev.co.uk \
--cc=desobei@outlook.com \
--cc=gregkh@linuxfoundation.org \
--cc=hsweeten@visionengravers.com \
--cc=linux-kernel@vger.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
all inboxes | Powered by JetHome®