Activity log for bug #1980767

Date Who What changed Old value New value Message
2022-07-05 17:54:32 Enrico Minack bug added bug
2022-07-05 17:57:37 Enrico Minack description 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: from lxml import etree     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)
2022-07-05 17:58:36 Enrico Minack description Parsing incomplete XML raises an XMLSyntaxError. But if a bespoke target is used, it fails to instantiate the error: from lxml import etree     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:     from lxml import etree     parser = etree.XMLParser(target=etree.TreeBuilder())     etree.fromstring('<a><b></b>', parser=parser) TypeError: __init__() takes at least 5 positional arguments (2 given) The following raises the error correctly:     parser = etree.XMLParser()     etree.fromstring('<a><b></b>', parser=parser) lxml.etree.XMLSyntaxError: Premature end of data in tag a line 1, line 1, column 11 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)
2022-07-06 10:03:58 Enrico Minack description Parsing incomplete XML raises an XMLSyntaxError. But if a bespoke target is used, it fails to instantiate the error:     from lxml import etree     parser = etree.XMLParser(target=etree.TreeBuilder())     etree.fromstring('<a><b></b>', parser=parser) TypeError: __init__() takes at least 5 positional arguments (2 given) The following raises the error correctly:     parser = etree.XMLParser()     etree.fromstring('<a><b></b>', parser=parser) lxml.etree.XMLSyntaxError: Premature end of data in tag a line 1, line 1, column 11 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:     from lxml import etree     parser = etree.XMLParser(target=etree.TreeBuilder())     etree.fromstring('<a><b></b>', parser=parser)     TypeError: __init__() takes at least 5 positional arguments (2 given) The following raises the error correctly:     parser = etree.XMLParser()     etree.fromstring('<a><b></b>', parser=parser)     lxml.etree.XMLSyntaxError: Premature end of data in tag a line 1, line 1, column 11 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. This issue also surfaces when any error is raised while processing the XML, which finally closes the TreeBuilder and throws another exception, because the processed XML has unclosed tags (as processing is half-way done). 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)
2023-11-03 09:33:26 scoder lxml: importance Undecided Low
2023-11-03 09:33:26 scoder lxml: status New Fix Committed
2023-11-03 09:33:26 scoder lxml: milestone 5.0
2023-11-03 09:33:26 scoder lxml: assignee scoder (scoder)
2023-12-17 12:00:58 scoder lxml: milestone 5.0 4.9.4
2023-12-21 10:28:47 scoder lxml: status Fix Committed Fix Released