What's New in Python 3.14 (copyediting)
Documentation
This is a meta-issue to capture PRs for copyedits to What's New in Python 3.14.
Other meta-issues:
- 3.13: #109975
- 3.12: #109190
Linked PRs
- gh-123300
- gh-125438
- gh-127028
- gh-128814
- gh-129970
- gh-132211
- gh-133082
- gh-133321
- gh-133452
- gh-133622
- gh-133771
- gh-135555
- gh-135602
- gh-135616
- gh-125566
A
I noticed a pet peeve in the what’s new (which is great otherwise — what a release!)
attributes = {"src": "shrubbery.jpg", "alt": "looks nice"}
template = t"<img {attributes} />"
assert html(template) == '<img src="shrubbery.jpg" alt="looks nice" class="looks-nice" />'
[ edit: better explanation on PR 132220 ]
HTML has some elements defined to not require a closing tag: <img src="..." alt="..."> is valid.
XML has a short form to condense opening and closing tags together: <img src="..." alt="..."/> is equivalent to <img src="..." alt="..."></img>. All opening tags need a matching closing tag, or the self-closing form.
A decade ago, to ensure compatibility with SGML and XML parsers, the best practice was to add a space before the slash. It was taking advantage of an SGML feature where / was actually closing the tag and > was ignored as garbage. It was ugly but compatible with the two kinds of parsers existing at the time.
Modern HTML does not require this, and has also abandoned XML rules (except for SVG that can be embedded directly, but that’s defined in the HTML spec I think).
So the easy, simple, correct form should be:
attributes = {"src": "shrubbery.jpg", "alt": "looks nice"}
template = t"<img {attributes}>"
assert html(template) == '<img src="shrubbery.jpg" alt="looks nice" class="looks-nice">'
Thanks for coming to my TED talk.
@merwok Would you like to open a PR to fix it?
Fine #133622
Python 3.14 is out! 🚀