The bug stems from a non-cleaned-up nsmap-property:
>>> x = etree.fromstring('<div xmlns="foo"/>') >>> x.tag = 'div' >>> assert etree.fromstring(etree.tostring(x)).tag == 'div' Traceback (most recent call last): File "<input>", line 1, in <module> AssertionError
>>> x.nsmap {None: 'foo'}
The bug stems from a non-cleaned-up nsmap-property:
>>> x = etree.fromstrin g('<div xmlns="foo"/>') g(etree. tostring( x)).tag == 'div'
>>> x.tag = 'div'
>>> assert etree.fromstrin
Traceback (most recent call last):
File "<input>", line 1, in <module>
AssertionError
>>> x.nsmap
{None: 'foo'}