Parsing incomplete XML raises TypeError: __init__() takes at least 5 positional arguments (2 given)
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
lxml |
Fix Released
|
Low
|
scoder |
Bug 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
etree.
TypeError: __init__() takes at least 5 positional arguments (2 given)
The following raises the error correctly:
parser = etree.XMLParser()
etree.
lxml.
It looks like TreeBuilder.close() calls (https:/
raise XMLSyntaxAssert
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_
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)
description: | updated |
description: | updated |
description: | updated |
Changed in lxml: | |
milestone: | 5.0 → 4.9.4 |
Changed in lxml: | |
status: | Fix Committed → Fix Released |
Thanks. Fixed in https:/ /github. com/lxml/ lxml/commit/ 762f62c5a1ab62c e37397aeeab2c27 fdcc14ca66