xml: TypeError: write() got an unexpected keyword argument 'short_empty_elements'
Nagy László Zsolt
gandalf at shopzeus.com
Fri Sep 22 08:18:51 EDT 2017
Here is an MWE:
import io
from lxml import etree
test_node = etree.fromstring('''
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://docs.oasis-open.org/ws-sx/ws-trust/200512">
<soap:Body>
<ns1:RequestSecurityToken/>
</soap:Body>
</soap:Envelope>''')
output = io.BytesIO(b'<?xml version="1.0" encoding="UTF-8"?>')
test_node.getroottree().write(output,
encoding="UTF-8",
xml_declaration=None,
default_namespace=None,
method="c14n",
short_empty_elements=False
)
output.seek(0)
print(output.read())
Result:
Traceback (most recent call last):
File "C:/not_telling/c14n.py", line 16, in <module>
short_empty_elements=False
File "lxml.etree.pyx", line 1869, in lxml.etree._ElementTree.write
(src\lxml\lxml.etree.c:57004)
TypeError: write() got an unexpected keyword argument 'short_empty_elements'
I have tracked down this to:
https://github.com/python/cpython/blob/master/Lib/xml/etree/ElementTree.py#L721
This method does have a "short_empty_elements" argument, but if I set it
to True, then it fails with TypeError.
Is this a bug?
More information about the Python-list
mailing list