| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead. |
Sorry, something went wrong.
|
@bkap123 cheers for the review. While I'm at it, do I need to make the same change over on #144845 (the SubElement one) as well, or is that alright as is? |
Sorry, something went wrong.
|
This PR changes the behavior of the public APIs and may affect users' code, so a news entry is required. #144845 is the same. |
Sorry, something went wrong.
|
Thanks for the reminder! I've added news entries to both PRs. |
Sorry, something went wrong.
Left small suggestion |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM. 👍
Sorry, something went wrong.
| an optional dictionary, containing element attributes. *extra* contains | ||
| additional attributes, given as keyword arguments. | ||
|
|
||
| .. versionchanged:: 3.15 |
There was a problem hiding this comment.
| .. versionchanged:: 3.15 | |
| .. versionchanged:: next |
Sorry, something went wrong.
|
|
||
| # 'attrib' can be passed as keyword | ||
| e = ET.Element('e', attrib={'key': 'value'}) | ||
| self.assertEqual(e.get('key'), 'value') |
There was a problem hiding this comment.
Maybe test also the attribute name 'attrib'?
Sorry, something went wrong.
|
Closing in favour of #144845, which already includes this change. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Make tag positional-only in xml.etree.ElementTree.Element.__init__ to match the C accelerator.
The C implementation (_elementtree.Element) uses PyArg_ParseTuple, which inherently makes tag positional-only. The Python fallback used def __init__(self, tag, attrib={}, **extra): which allowed tag as a keyword argument. This inconsistency meant Element(tag="foo") worked only when the C accelerator was unavailable.
Same pattern as gh-144270 (SubElement).
Fix: add / after tag → def __init__(self, tag, /, attrib={}, **extra):
Changes
📚 Documentation preview 📚: https://cpython-previews--144876.org.readthedocs.build/