Skip to content

gh-149571: Make Element.itertext consistent for Comment and ProcessingInstruction#149714

Closed
hardiksingh5864 wants to merge 6 commits into
python:mainfrom
hardiksingh5864:feature/bug
Closed

gh-149571: Make Element.itertext consistent for Comment and ProcessingInstruction#149714
hardiksingh5864 wants to merge 6 commits into
python:mainfrom
hardiksingh5864:feature/bug

Conversation

@hardiksingh5864

@hardiksingh5864 hardiksingh5864 commented May 12, 2026

Copy link
Copy Markdown

This fixes a behavior mismatch between the pure-Python and C implementations of xml.etree.ElementTree.Element.itertext()
Added regression coverage in Lib/test/test_xml_etree.py

@bedevere-app

bedevere-app Bot commented May 12, 2026

Copy link
Copy Markdown

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.

@python-cla-bot

python-cla-bot Bot commented May 12, 2026

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@StanFromIreland StanFromIreland left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems you ran a linter, causing a massive diff. Please revert the unrelated changes.

@bedevere-app

bedevere-app Bot commented May 12, 2026

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@hardiksingh5864

Copy link
Copy Markdown
Author

It seems you ran a linter, causing a massive diff. Please revert the unrelated changes.

It seems you ran a linter, causing a massive diff. Please revert the unrelated changes.

I have made the requested changes; please review again

@bedevere-app

bedevere-app Bot commented May 12, 2026

Copy link
Copy Markdown

Thanks for making the requested changes!

@StanFromIreland: please review the changes made to this pull request.

@bedevere-app bedevere-app Bot requested a review from StanFromIreland May 12, 2026 20:11
@hardiksingh5864

Copy link
Copy Markdown
Author

@StanFromIreland please review the changes made to this pull request.

@StanFromIreland

Copy link
Copy Markdown
Member

Sorry I'm not an expert in these modules, I requested Serhiy.

@serhiy-storchaka

Copy link
Copy Markdown
Member

Don't rush. First we need to decide which behavior is more desirable.

@hardiksingh5864

Copy link
Copy Markdown
Author

Don't rush. First we need to decide which behavior is more desirable.

I’ll hold off on working on a fix until the expected behavior is clearer. Once confirmed about the desired behavior please share that to me as well

@scoder

scoder commented May 16, 2026

Copy link
Copy Markdown
Contributor

First we need to decide which behavior is more desirable.

Comments and PIs should not contribute to the text returned by .itertext(). Comments are literally meant to add notes to the document that do not contribute to the document's processed content. It makes no sense to bother users with it. If they really want them to be included, it's easy to write an iterator that does include them, easier than excluding them, really. The built-in tool behaviour should follow the normal case of excluding them.

@serhiy-storchaka

Copy link
Copy Markdown
Member

It was decided to move in opposite direction.

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.

4 participants