etree.cleanup_namespaces does not remove a wrapping namespace in an unwrapped subtree
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
lxml |
New
|
Undecided
|
Unassigned |
Bug Description
This may either be a bug or a misunderstanding on my side.
I have an XML document with a wrapper namespace, and I am extracting the payload from a subtree. I want to get rid of the wrapper namespace, but using etree.cleanup_
Here is a short example REPL session:
>>> from lxml import etree
>>> tree = etree.fromstrin
>>> tree
<Element {http://
>>> etree.tostring(
b'<wrap:moep xmlns:wrap="http://
>>> foo = tree.find('{http://
>>> etree.tostring(foo)
b'<foo xmlns="http://
>>> etree.cleanup_
>>> etree.tostring(foo)
b'<foo xmlns="http://
I would expect the xmlns:wrap to have been removed. Am I missing something, or is this a bug?
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)