Hi!
lxml seems to raise AssertionErrors quite often. How should they be
interpreted? My understanding is that AssertionErrors in general should be
interpreted as "this thing that shouldn't happen just happened", i.e.
basically a bug rather than an error that's part of the interface.
Since I get them as often as I do I'm wondering if lxml uses a different
interpretation, that AssertionErrors are part of lxml's interface.
For example here's a code snippet that raises an AssertionError (lxml
4.5.2, macOS 10.15.6):
parser = XMLParser(target=TreeBuilder())
parser.feed('</a>')
And this is the exception stack:
Traceback (most recent call last):
File "src/lxml/parsertarget.pxi", line 158, in
lxml.etree._TargetParserContext._handleParseResult
File "src/lxml/parser.pxi", line 654, in lxml.etree._raiseParseError
File "<string>", line 1
lxml.etree.XMLSyntaxError: StartTag: invalid element name, line 1, column 2
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "src/lxml/parser.pxi", line 1256, in lxml.etree._FeedParser.feed
File "src/lxml/parser.pxi", line 1384, in lxml.etree._FeedParser.feed
File "src/lxml/parsertarget.pxi", line 167, in
lxml.etree._TargetParserContext._handleParseResult
File "src/lxml/saxparser.pxi", line 811, in lxml.etree.TreeBuilder.close
AssertionError: missing toplevel element
Should I interpret this AssertionError as a bug in lxml?
Thank you!
Per