Skip to content

Commit 66f95ea

Browse files
authored
gh-114737: Revert change to ElementTree.iterparse "root" attribute (GH-114755)
Prior to gh-114269, the iterator returned by ElementTree.iterparse was initialized with the root attribute as None. This restores the previous behavior.
1 parent b7688ef commit 66f95ea

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

Lib/test/test_xml_etree.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,9 @@ def test_iterparse(self):
536536
iterparse = ET.iterparse
537537

538538
context = iterparse(SIMPLE_XMLFILE)
539+
self.assertIsNone(context.root)
539540
action, elem = next(context)
541+
self.assertIsNone(context.root)
540542
self.assertEqual((action, elem.tag), ('end', 'element'))
541543
self.assertEqual([(action, elem.tag) for action, elem in context], [
542544
('end', 'element'),

Lib/xml/etree/ElementTree.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1256,8 +1256,8 @@ def __del__(self):
12561256
source.close()
12571257

12581258
it = IterParseIterator()
1259+
it.root = None
12591260
wr = weakref.ref(it)
1260-
del IterParseIterator
12611261
return it
12621262

12631263

0 commit comments

Comments
 (0)