Skip to content

Element.append() does not work with defusedxml? #43

Closed
@papadeltasierra

Description

See the script below. This works as expected.

# from defusedxml.ElementTree import fromstring
import xml.etree.ElementTree as ET

THE_XML = "<ListOfItems></ListOfItems>"
# xml = fromstring(THE_XML)
xml = ET.fromstring(THE_XML)
item = ET.Element('Item')
xml.append(item)

However it I swap for the version that uses defusedxml then I get this error:

Traceback (most recent call last):
File "c:\temp\defusing.py", line 7, in <module>
    xml.append(item)
TypeError: append() argument must be xml.etree.ElementTree.Element, not Element

Is this caused by defusedxml or is this some subtle difference between the C and Python implementations of xml.etree.Elementree?

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions