diff options
author | Matti Picus <matti.picus@gmail.com> | 2020-11-20 12:48:14 +0200 |
---|---|---|
committer | Matti Picus <matti.picus@gmail.com> | 2020-11-20 12:48:14 +0200 |
commit | f6f6ffbda7dd7a2af8a615e937438bb1336ae7b7 (patch) | |
tree | f6f8bfaa46525f326409e24aae0cd26d5047581e /lib-python | |
parent | document merged branch (diff) | |
download | pypy-f6f6ffbda7dd7a2af8a615e937438bb1336ae7b7.tar.gz pypy-f6f6ffbda7dd7a2af8a615e937438bb1336ae7b7.tar.bz2 pypy-f6f6ffbda7dd7a2af8a615e937438bb1336ae7b7.zip |
test, fix xml default attribute values (issue 3333) (thanks obfusk)
Diffstat (limited to 'lib-python')
-rw-r--r-- | lib-python/2.7/test/test_xml_etree.py | 20 | ||||
-rw-r--r-- | lib-python/2.7/xml/etree/ElementTree.py | 2 |
2 files changed, 20 insertions, 2 deletions
diff --git a/lib-python/2.7/test/test_xml_etree.py b/lib-python/2.7/test/test_xml_etree.py index f6d5d17fc3..f1f1c21cd1 100644 --- a/lib-python/2.7/test/test_xml_etree.py +++ b/lib-python/2.7/test/test_xml_etree.py @@ -87,6 +87,19 @@ ENTITY_XML = """\ <document>&entity;</document> """ +# backport from https://github.com/python/cpython/pull/22987 +ATTLIST_XML = """\ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE Foo [ +<!ELEMENT foo (bar*)> +<!ELEMENT bar (#PCDATA)*> +<!ATTLIST bar xml:lang CDATA "eng"> +<!ENTITY qux "quux"> +]> +<foo> +<bar>&qux;</bar> +</foo> +""" def checkwarnings(*filters): def decorator(test): @@ -1002,6 +1015,13 @@ class ElementTreeTest(unittest.TestCase): method='html') self.assertEqual(serialized, expected) + # backported from https://github.com/python/cpython/pull/22987 + def test_attlist_default(self): + # Test default attribute values; See BPO 42151. + root = ET.fromstring(ATTLIST_XML) + self.assertEqual(root[0].attrib, + {'{http://www.w3.org/XML/1998/namespace}lang': 'eng'}) + # # xinclude tests (samples from appendix C of the xinclude specification) diff --git a/lib-python/2.7/xml/etree/ElementTree.py b/lib-python/2.7/xml/etree/ElementTree.py index dca69106d1..4cae355398 100644 --- a/lib-python/2.7/xml/etree/ElementTree.py +++ b/lib-python/2.7/xml/etree/ElementTree.py @@ -1226,7 +1226,6 @@ class _IterParseIterator(object): if event == "start": try: parser.ordered_attributes = 1 - parser.specified_attributes = 1 def handler(tag, attrib_in, event=event, append=append, start=self._parser._start_list): append((event, start(tag, attrib_in))) @@ -1505,7 +1504,6 @@ class XMLParser(object): # use new-style attribute handling, if supported try: self._parser.ordered_attributes = 1 - self._parser.specified_attributes = 1 parser.StartElementHandler = self._start_list except AttributeError: pass |