From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
To: Akira Yokosawa <akiyks@gmail.com>
Cc: Jonathan Corbet <corbet@lwn.net>,
linux-kernel@vger.kernel.org,
Linux Doc Mailing List <linux-doc@vger.kernel.org>
Subject: Re: [RFC 1/6] scripts/get_abi.py: make it backward-compatible with Python 3.6
Date: Wed, 5 Feb 2025 08:15:01 +0100 [thread overview]
Message-ID: <20250205081501.160180bc@foz.lan> (raw)
In-Reply-To: <4274a2f8-5ba5-45f3-80c5-2de54c44c06f@gmail.com>
Em Wed, 5 Feb 2025 11:37:52 +0900
Akira Yokosawa <akiyks@gmail.com> escreveu:
> Hi,
>
> Jonathan Corbet wrote:
> > Mauro Carvalho Chehab <mchehab+huawei@kernel.org> writes:
> >
> >> Despite being introduced on Python 3.6, the original implementation
> >> was too limited: it doesn't accept anything but the argument.
> >
> > The original implementation *of f-strings* ?
Yes. IMO, even the original version of f-strings is better than the legacy
way of using '"string" % (tuple)' or "str.format".
Besides that, there aren't many places where it uses expressions inside
f-strings.
> >
> >> Even on python 3.10.12, support was still limited, as more complex
> >> operations cause SyntaxError:
> >>
> >> Exception occurred:
> >> File ".../linux/Documentation/sphinx/kernel_abi.py", line 48, in <module>
> >> from get_abi import AbiParser
> >> File ".../linux/scripts/get_abi.py", line 525
> >> msg += f"{part}\n{"-" * len(part)}\n\n"
> >> ^
> >> SyntaxError: f-string: expecting '}'
> >>
> >> Replace f-strings by normal string concatenation when it doesn't
> >> work on Python 3.6.
> >>
> >> Reported-by: Akira Yokosawa <akiyks@gmail.com>
>
> You might want to add
>
> Closes: https://lore.kernel.org/2d4d3fd1-5fe2-4d18-9085-73f9ff930c2d@gmail.com/
>
> >> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
> >
> > So I'm curious ... later in the series, you make 3.9 the minimal version
> > for the kernel. Given that, is there value in adding compatibility for
> > older versions here?
No because 3.9 is still not enough to accept a valid Python expression on f-strings.
This arrived only on Python 3.12[1]:
"Expression components inside f-strings can now be any valid Python expression"
So, with this patch, doc build can be using Python 3.6. Still, it makes
sense to move minimal version to 3.9 due to the current status of other
Python scripts.
[1] https://docs.python.org/3/whatsnew/3.12.html#pep-701-syntactic-formalization-of-f-strings
> I think rewording the summary to
>
> "scripts/get_abi.py: make it backward-compatible with Python <3.11"
>
> would resolve Jon's confusion.
Sure, but IMO it is still valuable to say somewhere that the script
was tested and it is known to work since Python 3.6.
>
> I haven't looked into python3'changelog, but it might be
> "... backward-compatible with Python <3.12".
> Mauro, which python3 release extended the f-string implementation?
See above. I only did a quick check, but it sounds that 3.12 is the
one that finally implemented f-strings properly in a similar way to
what Perl 5 does with $'expression' inside strings.
Thanks,
Mauro
next prev parent reply other threads:[~2025-02-05 7:15 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-29 16:09 [RFC 0/6] Raise the bar with regards to Python and Sphinx requirements Mauro Carvalho Chehab
2025-01-29 16:09 ` [RFC 1/6] scripts/get_abi.py: make it backward-compatible with Python 3.6 Mauro Carvalho Chehab
2025-01-30 7:34 ` Akira Yokosawa
2025-02-04 17:28 ` Jonathan Corbet
2025-02-05 2:37 ` Akira Yokosawa
2025-02-05 7:15 ` Mauro Carvalho Chehab [this message]
2025-02-05 9:40 ` Akira Yokosawa
2025-01-29 16:09 ` [RFC 2/6] docs: extensions: don't use utf-8 syntax for descriptions Mauro Carvalho Chehab
2025-02-04 17:24 ` Jonathan Corbet
2025-01-29 16:09 ` [RFC 3/6] docs: automarkup: drop legacy support Mauro Carvalho Chehab
2025-01-29 16:09 ` [RFC 4/6] scripts/kernel-doc: drop Sphinx version check Mauro Carvalho Chehab
2025-01-29 16:09 ` [RFC 5/6] docs: changes: update Sphinx minimal version to 3.4.3 Mauro Carvalho Chehab
2025-01-29 16:09 ` [RFC 6/6] doc: changes: update Python minimal version Mauro Carvalho Chehab
2025-01-30 9:33 ` [RFC 0/6] Raise the bar with regards to Python and Sphinx requirements Donald Hunter
2025-01-30 14:31 ` Jonathan Corbet
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=20250205081501.160180bc@foz.lan \
--to=mchehab+huawei@kernel.org \
--cc=akiyks@gmail.com \
--cc=corbet@lwn.net \
--cc=linux-doc@vger.kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).