New submission from Jack Jansen <jackjan...@users.sourceforge.net>:

When using a TreeBuilder with a custom factory (returning a subclass of Element 
with some extra functionality) there is an issue with findall().

XPaths using an indexed predicate no longer work: the findall() result is 
always empty. The attached test script shows the problem.

I have analysed this as far as finding that the issue is in 
ElementPath.prepare_predicate.<locals>.select(), the last one. Specifically, 
the statement
    elems = list(parent.findall(elem.tag))
always returns an empty list (if the Element class is subclassed).

When using Python 2.7 everything works fine. When adding a findall() method to 
the Element subclass that simply calls Element.findall() everything also works 
fine. I suspect some issue with the _elementtree C implementation but I don't 
understand it.

----------
components: Library (Lib)
files: testetns.py
messages: 327385
nosy: jackjansen
priority: normal
severity: normal
stage: needs patch
status: open
title: xml.etree.ElementTree findall() fails when using custom TreeBuilder
type: behavior
versions: Python 3.7
Added file: https://bugs.python.org/file47859/testetns.py

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue34941>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to