You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Modules/_elementtree.c still has four places which accept bytes. They are the result of improper translation of the PyString C API used in Python 2 to PyBytes (72b710a). The Python implementation of xml.etree.ElementTree accepts only str there, and gh-72424 declared bytes unsupported.
checkpath() checks a bytes path for XPath characters, so find(), findall() and findtext() with a bytes path return None/[]/'' instead of raising TypeError like iterfind() and the Python implementation.
Bug report
Modules/_elementtree.cstill has four places which acceptbytes. They are the result of improper translation of thePyStringC API used in Python 2 toPyBytes(72b710a). The Python implementation ofxml.etree.ElementTreeaccepts onlystrthere, and gh-72424 declared bytes unsupported.checkpath()checks a bytes path for XPath characters, sofind(),findall()andfindtext()with a bytes path returnNone/[]/''instead of raisingTypeErrorlikeiterfind()and the Python implementation.Element.iter()treatsb'*'as a wildcard.XMLParser._setevents()accepts bytes event names, likeb'start'. The Python implementation raisesValueError; the events were documented as strings in cElementTree iterparse requires events as bytes; ElementTree uses strings #53503.treebuilder_handle_data()concatenates a one-bytebytesto abytes. It is dead code: the parser always passesstr.Linked PRs