]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-43399: Fix ElementTree.extend not working on iterators (GH-24751)
authorAlex Prengère <2138730+alexprengere@users.noreply.github.com>
Tue, 30 Mar 2021 21:11:29 +0000 (23:11 +0200)
committerGitHub <noreply@github.com>
Tue, 30 Mar 2021 21:11:29 +0000 (00:11 +0300)
Lib/test/test_xml_etree.py
Lib/xml/etree/ElementTree.py
Misc/ACKS
Misc/NEWS.d/next/Library/2021-03-04-17-53-46.bpo-43399.Wn95u-.rst [new file with mode: 0644]

index fcb1f7fdfbbde54b18cb0e5998a08d85f0c09c94..553529a30017027336b9202f30bacffc06cfe954 100644 (file)
@@ -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
index 168418e466c45223fde8957ca997a956b298afbb..99246800b98663d2c9e09cc2b4beff223685c6a2 100644 (file)
@@ -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*."""
index 5d3f75a4165b11d3504bcd493f04e91ae083be51..42f0efdd536ddc0b815e5ba92b17eb679744c9b3 100644 (file)
--- 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 (file)
index 0000000..0b8dffb
--- /dev/null
@@ -0,0 +1,2 @@
+Fix ``ElementTree.extend`` not working on iterators when using the
+Python implementation