8000 [3.11] gh-114737: Revert change to ElementTree.iterparse "root" attri… · python/cpython@3982049 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3982049

Browse files
[3.11] gh-114737: Revert change to ElementTree.iterparse "root" attribute (GH-114755) (GH-114799)
Prior to gh-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 3982049

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