Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
serhiy-storchaka merged 4 commits into
python:mainfrom
serhiy-storchaka:gh-63102-pull-target
Sep 13, 2026
Merged

gh-63102: Support custom targets in the pull parser#156888
serhiy-storchaka merged 4 commits 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

read-the-docs-community Bot commented Sep 3, 2026

Copy link
Copy Markdown

Documentation build overview

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

  🔍 Preview build  

43 files changed · + 1 added · ± 41 modified · - 1 deleted

+ Added

± Modified

- Deleted

TypeError is raised in the constructor if the target does not implement
start(), end(), comment() or pi() for the corresponding event, in both
implementations.  The C implementation silently reported nothing and
the Python implementation raised AttributeError while parsing.
@serhiy-storchaka
serhiy-storchaka enabled auto-merge (squash) September 13, 2026 10:42
@serhiy-storchaka
serhiy-storchaka merged commit a2f4f19 into python:main Sep 13, 2026
100 of 102 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant