summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2021-03-30 21:32:55 (GMT)
committerGitHub <noreply@github.com>2021-03-30 21:32:55 (GMT)
commitc1079cde2a7676892a9b98703903206b7d26ed1f (patch)
treea63a054da156f6b4a172230c4f2d33c3a78cd134
parent9ac263091db4a8c7dedb577d01f544622a448744 (diff)
downloadcpython-c1079cde2a7676892a9b98703903206b7d26ed1f.zip
cpython-c1079cde2a7676892a9b98703903206b7d26ed1f.tar.gz
cpython-c1079cde2a7676892a9b98703903206b7d26ed1f.tar.bz2
bpo-43399: Fix ElementTree.extend not working on iterators (GH-24751)
(cherry picked from commit 51a85ddce8b336addcb61b96f04c9c5edef07296) Co-authored-by: Alex Prengère <2138730+alexprengere@users.noreply.github.com>
-rw-r--r--Lib/test/test_xml_etree.py3
-rw-r--r--Lib/xml/etree/ElementTree.py2
-rw-r--r--Misc/ACKS1
-rw-r--r--Misc/NEWS.d/next/Library/2021-03-04-17-53-46.bpo-43399.Wn95u-.rst2
4 files changed, 7 insertions, 1 deletions
diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py
index 341a3c7..d41ff4f 100644
--- a/Lib/test/test_xml_etree.py
+++ b/Lib/test/test_xml_etree.py
@@ -314,6 +314,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 598b569..f8538df 100644
--- a/Lib/xml/etree/ElementTree.py
+++ b/Lib/xml/etree/ElementTree.py
@@ -245,7 +245,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 e181c61..39aa954 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -1334,6 +1334,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 0000000..0b8dffb
--- /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