summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2024-01-31 11:59:58 (GMT)
committerGitHub <noreply@github.com>2024-01-31 11:59:58 (GMT)
commit5d7b90db0cd463e69d15acf5498232b9bc2bfeaa (patch)
tree8babd901e2d0acf9a32af1c4afd3b4603f2f0aec /Lib
parent0536bbb192c5ecca5e21385f82b0ac86f2e7e34c (diff)
downloadcpython-5d7b90db0cd463e69d15acf5498232b9bc2bfeaa.zip
cpython-5d7b90db0cd463e69d15acf5498232b9bc2bfeaa.tar.gz
cpython-5d7b90db0cd463e69d15acf5498232b9bc2bfeaa.tar.bz2
[3.12] gh-114737: Revert change to ElementTree.iterparse "root" attribute (GH-114755) (GH-114798)
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 66f95ea6a65deff547cab0d312b8c8c8a4cf8beb) Co-authored-by: Sam Gross <colesbury@gmail.com>
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_xml_etree.py2
-rw-r--r--Lib/xml/etree/ElementTree.py2
2 files changed, 3 insertions, 1 deletions
diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py
index 53a4e9f..b50898f 100644
--- a/Lib/test/test_xml_etree.py
+++ b/Lib/test/test_xml_etree.py
@@ -536,7 +536,9 @@ class ElementTreeTest(unittest.TestCase):
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'),
diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py
index ae65750..bb7362d 100644
--- a/Lib/xml/etree/ElementTree.py
+++ b/Lib/xml/etree/ElementTree.py
@@ -1256,8 +1256,8 @@ def iterparse(source, events=None, parser=None):
source.close()
it = IterParseIterator()
+ it.root = None
wr = weakref.ref(it)
- del IterParseIterator
return it