diff options
| author | Sam Gross <colesbury@gmail.com> | 2024-01-31 11:22:24 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-31 11:22:24 (GMT) |
| commit | 66f95ea6a65deff547cab0d312b8c8c8a4cf8beb (patch) | |
| tree | 5cac9743bbbc47962ce321181adfba2575ec04e0 | |
| parent | b7688ef71eddcaf14f71b1c22ff2f164f34b2c74 (diff) | |
| download | cpython-66f95ea6a65deff547cab0d312b8c8c8a4cf8beb.zip cpython-66f95ea6a65deff547cab0d312b8c8c8a4cf8beb.tar.gz cpython-66f95ea6a65deff547cab0d312b8c8c8a4cf8beb.tar.bz2 | |
gh-114737: Revert change to ElementTree.iterparse "root" attribute (GH-114755)
Prior to gh-114269, the iterator returned by ElementTree.iterparse was
initialized with the root attribute as None. This restores the previous
behavior.
| -rw-r--r-- | Lib/test/test_xml_etree.py | 2 | ||||
| -rw-r--r-- | Lib/xml/etree/ElementTree.py | 2 |
2 files changed, 3 insertions, 1 deletions
diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py index b9e7937..221545b 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 |
