Parsing incomplete XML raises an XMLSyntaxError. But if a bespoke target is used, it fails to instantiate the error:
parser = etree.XMLParser(target=etree.TreeBuilder()) etree.fromstring('<a><b></b>', parser=parser)
The following raises the error correctly: parser = etree.XMLParser() etree.fromstring('<a><b></b>', parser=parser)
It looks like TreeBuilder.close() calls (https://github.com/lxml/lxml/blob/master/src/lxml/saxparser.pxi#L820):
raise XMLSyntaxAssertionError("missing end tags")
Which calls the XMLSyntaxError constructor with only two arguments (self and message) and not the expected 5.
Python : sys.version_info(major=3, minor=8, micro=13, releaselevel='final', serial=0) lxml.etree : (4, 9, 1, 0) libxml used : (2, 9, 14) libxml compiled : (2, 9, 14) libxslt used : (1, 1, 35) libxslt compiled : (1, 1, 35)
Parsing incomplete XML raises an XMLSyntaxError. But if a bespoke target is used, it fails to instantiate the error:
parser = etree.XMLParser (target= etree.TreeBuild er()) fromstring( '<a><b> </b>', parser=parser)
etree.
The following raises the error correctly: fromstring( '<a><b> </b>', parser=parser)
parser = etree.XMLParser()
etree.
It looks like TreeBuilder.close() calls (https:/ /github. com/lxml/ lxml/blob/ master/ src/lxml/ saxparser. pxi#L820):
raise XMLSyntaxAssert ionError( "missing end tags")
Which calls the XMLSyntaxError constructor with only two arguments (self and message) and not the expected 5.
Python : sys.version_ info(major= 3, minor=8, micro=13, releaselevel= 'final' , serial=0)
lxml.etree : (4, 9, 1, 0)
libxml used : (2, 9, 14)
libxml compiled : (2, 9, 14)
libxslt used : (1, 1, 35)
libxslt compiled : (1, 1, 35)