From 80860381a5582daf34d895f154281deb921cf9ed Mon Sep 17 00:00:00 2001 From: Senthil Kumaran Date: Tue, 9 Nov 2010 02:49:26 +0000 Subject: [PATCH] Merged revisions 86348 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r86348 | senthil.kumaran | 2010-11-09 10:36:59 +0800 (Tue, 09 Nov 2010) | 3 lines Fix Issue10205 - XML QName error when different tags have same QName. ........ --- Lib/test/test_xml_etree.py | 5 +++++ 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 90afdfdae6a..3f4455a8c99 100644 --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -1101,6 +1101,11 @@ def qname(): >>> elem = ET.Element(ET.QName("uri", "tag")) >>> serialize(elem) # 1.3 '' + >>> 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 + '' 2) decorated attributes diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py index 181a461d77f..d89fd3be0c3 100644 --- a/Lib/xml/etree/ElementTree.py +++ b/Lib/xml/etree/ElementTree.py @@ -871,8 +871,9 @@ def _namespaces(elem, encoding, 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, basestring): if tag not in qnames: add_qname(tag)