2020-02-28 12:18:26 |
Xavier (Open ERP) |
description |
The documentation of QName (https://lxml.de/api/lxml.etree.QName-class.html) states:
> You can pass QName objects wherever a tag name is expected.
The signature of `_Element.iter` is defined as:
> iter(self, tag=None, *tags)
from this one would expect to pass a QName directly to iter would work and filter on that qname, however
```
t = etree.fromstring("<root/>")
for node in t.iter(QName('http://example.org/ns', 'a')):
...
```
instead of doing nothing raises "TypeError: 'lxml.etree.QName' object is not iterable".
Workaround: str(QName(...)) but that's not great, and the documentation is still not correct.
Environment:
Python : sys.version_info(major=3, minor=6, micro=9, releaselevel='final', serial=0)
lxml.etree : (4, 5, 0, 0)
libxml used : (2, 9, 10)
libxml compiled : (2, 9, 10)
libxslt used : (1, 1, 34)
libxslt compiled : (1, 1, 34) |
The documentation of QName (https://lxml.de/api/lxml.etree.QName-class.html) states:
> You can pass QName objects wherever a tag name is expected.
The signature of `_Element.iter` is defined as:
> iter(self, tag=None, *tags)
from this one would expect to pass a QName directly to iter would work and filter on that qname, however
t = etree.fromstring("<root/>")
for node in t.iter(QName('http://example.org/ns', 'a')):
...
instead of doing nothing raises "TypeError: 'lxml.etree.QName' object is not iterable".
Workaround: str(QName(...)) but that's not great, and the documentation is still not correct.
Environment:
Python : sys.version_info(major=3, minor=6, micro=9, releaselevel='final', serial=0)
lxml.etree : (4, 5, 0, 0)
libxml used : (2, 9, 10)
libxml compiled : (2, 9, 10)
libxslt used : (1, 1, 34)
libxslt compiled : (1, 1, 34) |
|