test failure with libxml2 2.10.4
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
lxml |
Fix Released
|
Medium
|
scoder |
Bug Description
While attempting to build lxml against the recently released libxml2 2.10.4:
Traceback (most recent call last):
File "/usr/lib64/
yield
File "/usr/lib64/
self.
File "/usr/lib64/
method()
File "/home/
self.
AttributeError: 'NoneType' object has no attribute 'nsmap'
I've tracked this down to this line in the test case returning None
el = etree.HTML(
The release notes of libxml2 2.10.4 state a regression that namespaces are now ignored in HTML documents, but I'm not certain how best to handle this.
Changed in lxml: | |
status: | Fix Committed → Fix Released |
I've tried to change the tests like this:
def test_html_ prefix_ nsmap(self) : '<hha:page- description> aa</hha: page-descriptio n>') './/page- description' ) VERSION < (2, 10, 4): VERSION < (2, 9, 11):
self. assertEqual( {'hha': None}, el.nsmap)
self. assertEqual( {}, el.nsmap)
self. assertIsNone( el) './/hha: page-descriptio n') # <-- breaks
self. assertEqual( {}, el.nsmap)
etree = self.etree
html = etree.HTML(
el = html.find(
if etree.LIBXML_
if etree.LIBXML_
else:
else:
el = html.find(
But the marked line does not work as I expected:
======= ======= ======= ======= ======= ======= ======= ======= ======= ======= prefix_ nsmap (lxml.tests. test_etree. ETreeOnlyTestCa se.test_ html_prefix_ nsmap) ------- ------- ------- ------- ------- ------- ------- ------- ------- _elementpath. py", line 85, in lxml._elementpa th.xpath_ tokenizer
ERROR: test_html_
-------
Traceback (most recent call last):
File "src/lxml/
raise KeyError
KeyError
During handling of the above exception, another exception occurred:
Traceback (most recent call last): python3. 11/unittest/ case.py" , line 57, in testPartExecutor python3. 11/unittest/ case.py" , line 623, in run _callTestMethod (testMethod) python3. 11/unittest/ case.py" , line 579, in _callTestMethod build/BUILD/ lxml-4. 9.2/src/ lxml/tests/ test_etree. py", line 3080, in test_html_ prefix_ nsmap './/hha: page-descriptio n')
^^^^^ ^^^^^^^ ^^^^^^^ ^^^^^^^ ^^^^^^^ ^^^ etree.pyx" , line 1550, in lxml.etree. _Element. find find(self, path, namespaces) _elementpath. py", line 323, in lxml._elementpa th.find _elementpath. py", line 312, in lxml._elementpa th.iterfind path_iterator( path, namespaces) _elementpath. py", line 295, in lxml._elementpa th._build_ path_iterator append( ops[token[ 0]](_next, token)) _elementpath. py", line 120, in lxml._elementpa th.prepare_ descendant _elementpath. py", line 88, in xpath_tokenizer
File "/usr/lib64/
yield
File "/usr/lib64/
self.
File "/usr/lib64/
if method() is not None:
^^^^^^^^
File "/builddir/
el = html.find(
File "src/lxml/
return _elementpath.
File "src/lxml/
it = iterfind(elem, path, namespaces)
File "src/lxml/
selector = _build_
File "src/lxml/
selector.
File "src/lxml/
token = next()
File "src/lxml/
raise SyntaxError("prefix %r not found in prefix map" % prefix)
SyntaxError: prefix 'hha' not found in prefix map
------- ------- ------- ------- ------- ------- ------- ------- ------- -------
Ran 1979 tests in 5.332s