# defusedxml 导致 xml.etree.ElementTree.Element 异常

SubElement() argument 1 must be xml.etree.ElementTree.Element, not Element


ElementTree in its C version is very picky about the exact class that is being passed in. So that if the elements come from a file loading the python version of ElementTree, you can't insert them in your ElementTree. Even if they're both loading the C-version of ElementTree (cElementTree before Python 3.3), if they're not loading from the same binary file (one is inside the virtual environment, one is outside, for instance), then this message appears (formerly the even more cryptic argument 1 must be Element, not Element message).

defusedxml 库用来解决 XML 的安全性问题（ Python 自带的 xml.etree.ElementTree 模块对于恶意构建的数据是不安全的），没想到自己引入这么大的问题。

Q. E. D.

IT » nginx