8000 bpo-43399: Fix ElementTree.extend not working on iterators (GH-24751) · python/cpython@c1079cd · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit c1079cd

Browse files
bpo-43399: Fix ElementTree.extend not working on iterators (GH-24751)
(cherry picked from commit 51a85dd) Co-authored-by: Alex Prengère <2138730+alexprengere@users.noreply.github.com>
1 parent 9ac2630 commit c1079cd

File tree

4 files changed

+7
-1
lines changed

4 files changed

+7
-1
lines changed

Lib/test/test_xml_etree.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,9 @@ def test_simpleops(self):
314314
elem.extend([e])
315315
self.serialize_check(elem, '<body><tag /><tag2 /></body>')
316316
elem.remove(e)
317+
elem.extend(iter([e]))
318+
self.serialize_check(elem, '<body><tag /><tag2 /></body>')
319+
elem.remove(e)
317320

318321
element = ET.Element("tag", key="value")
319322
self.serialize_check(element, '<tag key="value" />') # 1

Lib/xml/etree/ElementTree.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ def extend(self, elements):
245245
"""
246246
for element in elements:
247247
self._assert_is_element(element)
248-
self._children.extend(elements)
248+
self._children.append(element)
249249

250250
def insert(self, index, subelement):
251251
"""Insert *subelement* at position *index*."""

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,6 +1334,7 @@ Matheus Vieira Portela
13341334
Davin Potts
13351335
Guillaume Pratte
13361336
Florian Preinstorfer
1337+
Alex Prengère
13371338
Amrit Prem
13381339
Paul Prescod
13391340
Donovan Preston
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix ``ElementTree.extend`` not working on iterators when using the
2+
Python implementation

0 commit comments

Comments
 (0)
0