8000 gh-114737: Revert change to ElementTree.iterparse "root" attribute (G… · miss-islington/cpython@e842682 · GitHub
[go: up one dir, main page]

Skip to content

Commit e842682

Browse files
colesburymiss-islington
authored andcommitted
pythongh-114737: Revert change to ElementTree.iterparse "root" attribute (pythonGH-114755)
Prior to pythongh-114269, the iterator returned by ElementTree.iterparse was initialized with the root attribute as None. This restores the previous behavior. (cherry picked from commit 66f95ea) Co-authored-by: Sam Gross <colesbury@gmail.com>
1 parent ad62333 commit e842682

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
@@ -1271,8 +1271,8 @@ def __del__(self):
12711271
source.close()
12721272

12731273
it = IterParseIterator()
1274+
it.root = None
12741275
wr = weakref.ref(it)
1275-
del IterParseIterator
12761276
return it
12771277

12781278

0 commit comments

Comments
 (0)
0