diff options
-rw-r--r-- | Lib/test/test_xml_etree.py | 5 | ||||
-rw-r--r-- | Lib/xml/etree/ElementTree.py | 5 |
2 files changed, 8 insertions, 2 deletions
diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py index e802359..08f7988 100644 --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -1119,6 +1119,11 @@ def qname(): >>> elem = ET.Element(ET.QName("uri", "tag")) >>> serialize(elem) # 1.3 '<ns0:tag xmlns:ns0="uri" />' + >>> elem = ET.Element(ET.QName("uri", "tag")) + >>> subelem = ET.SubElement(elem, ET.QName("uri", "tag1")) + >>> subelem = ET.SubElement(elem, ET.QName("uri", "tag2")) + >>> serialize(elem) # 1.4 + '<ns0:tag xmlns:ns0="uri"><ns0:tag1 /><ns0:tag2 /></ns0:tag>' 2) decorated attributes diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py index 9f5717e..75fbea9 100644 --- a/Lib/xml/etree/ElementTree.py +++ b/Lib/xml/etree/ElementTree.py @@ -913,8 +913,9 @@ def _namespaces(elem, default_namespace=None): iterate = elem.getiterator # cET compatibility for elem in iterate(): tag = elem.tag - if isinstance(tag, QName) and tag.text not in qnames: - add_qname(tag.text) + if isinstance(tag, QName): + if tag.text not in qnames: + add_qname(tag.text) elif isinstance(tag, str): if tag not in qnames: add_qname(tag) |