diff options
author | Alex Prengère <2138730+alexprengere@users.noreply.github.com> | 2021-03-30 23:11:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-31 00:11:29 +0300 |
commit | 51a85ddce8b336addcb61b96f04c9c5edef07296 (patch) | |
tree | 5206be9be09a2523341723e4478c731bee24accb | |
parent | 73b20ae2fb7a5c1374aa5c3719f64c53d29fa0d2 (diff) | |
download | cpython-51a85ddce8b336addcb61b96f04c9c5edef07296.tar.gz cpython-51a85ddce8b336addcb61b96f04c9c5edef07296.zip |
bpo-43399: Fix ElementTree.extend not working on iterators (GH-24751)
-rw-r--r-- | Lib/test/test_xml_etree.py | 3 | ||||
-rw-r--r-- | Lib/xml/etree/ElementTree.py | 2 | ||||
-rw-r--r-- | Misc/ACKS | 1 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Library/2021-03-04-17-53-46.bpo-43399.Wn95u-.rst | 2 |
4 files changed, 7 insertions, 1 deletions
diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py index fcb1f7fdfbb..553529a3001 100644 --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -330,6 +330,9 @@ class ElementTreeTest(unittest.TestCase): elem.extend([e]) self.serialize_check(elem, '<body><tag /><tag2 /></body>') elem.remove(e) + elem.extend(iter([e])) + self.serialize_check(elem, '<body><tag /><tag2 /></body>') + elem.remove(e) element = ET.Element("tag", key="value") self.serialize_check(element, '<tag key="value" />') # 1 diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py index 168418e466c..99246800b98 100644 --- a/Lib/xml/etree/ElementTree.py +++ b/Lib/xml/etree/ElementTree.py @@ -252,7 +252,7 @@ class Element: """ for element in elements: self._assert_is_element(element) - self._children.extend(elements) + self._children.append(element) def insert(self, index, subelement): """Insert *subelement* at position *index*.""" diff --git a/Misc/ACKS b/Misc/ACKS index 5d3f75a4165..42f0efdd536 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -1381,6 +1381,7 @@ Matheus Vieira Portela Davin Potts Guillaume Pratte Florian Preinstorfer +Alex Prengère Amrit Prem Paul Prescod Donovan Preston diff --git a/Misc/NEWS.d/next/Library/2021-03-04-17-53-46.bpo-43399.Wn95u-.rst b/Misc/NEWS.d/next/Library/2021-03-04-17-53-46.bpo-43399.Wn95u-.rst new file mode 100644 index 00000000000..0b8dffb2312 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2021-03-04-17-53-46.bpo-43399.Wn95u-.rst @@ -0,0 +1,2 @@ +Fix ``ElementTree.extend`` not working on iterators when using the +Python implementation |