Skip to content

gh-63102: Support custom targets in the pull parser - #156888

Open
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:gh-63102-pull-target
Open

gh-63102: Support custom targets in the pull parser#156888
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:gh-63102-pull-target

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Sep 3, 2026

Copy link
Copy Markdown
Member

In the C implementation the list of events was collected by the TreeBuilder, so the pull parser only worked with the standard target. The parser itself now collects the events and reports what the target returns.

XMLPullParser and iterparse() get the target parameter, which makes it possible to parse a large document incrementally without building a tree for it.

The namespace events no longer need a separate code path: the parser reports the prefix and the URI if the target does not implement start_ns() and end_ns(), as the Python implementation already did.

The list of events was collected by the TreeBuilder in the C implementation,
so the pull parser only worked with the standard target.  The parser itself
now collects the events, and reports what the target returns.  XMLPullParser
and iterparse() get the target parameter, which makes it possible to parse a
large document incrementally without building a tree for it.

The namespace events no longer need a separate code path: the parser reports
the prefix and the uri if the target does not implement start_ns()/end_ns(),
as the Python implementation already did.
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #34371485 | 📁 Comparing aceee9a against main (50ed1ec)

  🔍 Preview build  

3 files changed
± library/xml.etree.elementtree.html
± whatsnew/3.16.html
± whatsnew/changelog.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant