[issue42893] Strange XPath search behavior of xml.etree.ElementTree.Element.find

2021-01-14 Thread robpats
robpats added the comment: Thanks for the pointer. I didn't notice this paragraph. xml.etree.ElementTree.Element.find currently returns None if XPath expression is invalid or unsupported. I think it should also return None if position predicates are not preceded by a tag name. It would be

[issue42893] Strange XPath search behavior of xml.etree.ElementTree.Element.find

2021-01-13 Thread Christian Heimes
Christian Heimes added the comment: etree's find method supports a limited subset of XPath, https://docs.python.org/3/library/xml.etree.elementtree.html#supported-xpath-syntax . e.find("./*[2]") seems to trigger undefined behavior. The limited XPath syntax for positions is documented as

[issue42893] Strange XPath search behavior of xml.etree.ElementTree.Element.find

2021-01-11 Thread robpats
New submission from robpats : Python 3.6.8 / 3.7.9 / 3.8.7 >>> import xml.etree.ElementTree >>> e = xml.etree.ElementTree.fromstring('>> class="row"/>') >>> list(e) [, , , , , ] >>> e.find("./div[1]") >>> e.find("./div[2]") >>> e.find("./div[3]") >>> e.find("./hr[1]") >>>