8000 gh-114737: Revert change to ElementTree.iterparse "root" attribute · colesbury/cpython@212ef9f · GitHub
[go: up one dir, main page]

Skip to content

Commit 212ef9f

Browse files
committed
pythongh-114737: Revert change to ElementTree.iterparse "root" attribute
Prior to pythongh-114269, the iterator returned by ElementTree.iterparse was initialized with the root attribute as None. This restores the previous behavior.
1 parent 0990d55 commit 212ef9f

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

Lib/test/test_xml_etree.py

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

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

Lib/xml/etree/ElementTree.py

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

12581258
it = IterParseIterator()
1259+
it.root = None
12591260
wr = weakref.ref(it)
1260-
del IterParseIterator
1261+
del iterator, IterParseIterator
12611262
return it
12621263

12631264

0 commit comments

Comments
 (0)
0