gh-157366: Remove leftover bytes support from _elementtree - #157367
Merged
serhiy-storchaka merged 2 commits intoSep 12, 2026
Conversation
It was the result of improper translation of the PyString C API used in Python 2 to PyBytes. The Python implementation accepts only str there. * checkpath() no longer checks a bytes path for XPath characters, so find(), findall() and findtext() with a bytes path now raise TypeError, like iterfind() and the Python implementation. * Element.iter() no longer treats b'*' as a wildcard. * XMLParser no longer accepts bytes event names. Non-str event names are now reported as "unknown event", like in the Python implementation. * Remove the dead code for concatenating one-byte bytes in TreeBuilder.
Member
|
The change is correct because when bytes support is removed, there is still a similar code for str support. data() only had bytes and list support, but the bytes support is a mistake and it should be removed. In Python 3, data must be str, not bytes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
It was the result of improper translation of the PyString C API used in Python 2 to PyBytes. The Python implementation accepts only str there.
checkpath()no longer checks a bytes path for XPath characters, sofind(),findall()andfindtext()with a bytes path now raise TypeError, likeiterfind()and the Python implementation.Element.iter()no longer treatsb'*'as a wildcard.XMLParserno longer accepts bytes event names. Non-str event names are now reported as "unknown event", like in the Python implementation.TreeBuilder.