8000 [3.12] gh-114737: Revert change to ElementTree.iterparse "root" attribute (GH-114755) by miss-islington · Pull Request #114798 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

[3.12] gh-114737: Revert change to ElementTree.iterparse "root" attribute (GH-114755) #114798

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
gh-114737: Revert change to ElementTree.iterparse "root" attribute (G…
…H-114755)

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>
  • Loading branch information
colesbury authored and miss-islington committed Jan 31, 2024
commit 8ebd614b3085c12ad7e7894919185c044a8f9cde
2 changes: 2 additions & 0 deletions Lib/test/test_xml_etree.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,9 @@ def test_iterparse(self):
iterparse = ET.iterparse

context = iterparse(SIMPLE_XMLFILE)
self.assertIsNone(context.root)
action, elem = next(context)
self.assertIsNone(context.root)
self.assertEqual((action, elem.tag), ('end', 'element'))
self.assertEqual([(action, elem.tag) for action, elem in context], [
('end', 'element'),
Expand Down
2 changes: 1 addition & 1 deletion Lib/xml/etree/ElementTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -1256,8 +1256,8 @@ def __del__(self):
source.close()

it = IterParseIterator()
it.root = None
wr = weakref.ref(it)
del IterParseIterator
return it


Expand Down
0