Commit b2b759ff authored by Nick Pope's avatar Nick Pope Committed by GitHub

Prefer Element.iter() over the deprecated Element.getiterator(). (GH-3865)

`xml.etree.ElementTree.Element.getiterator()` was deprecated in Python
2.7 & 3.2 and removed in Python 3.9.
parent 7fae6c9d
...@@ -429,7 +429,11 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -429,7 +429,11 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
except ImportError: except ImportError:
import xml.etree.ElementTree as ET import xml.etree.ElementTree as ET
coverage_xml = ET.parse(coverage_xml_filename).getroot() coverage_xml = ET.parse(coverage_xml_filename).getroot()
for el in coverage_xml.getiterator(): if hasattr(coverage_xml, 'iter'):
iterator = coverage_xml.iter() # Python 2.7 & 3.2+
else:
iterator = coverage_xml.getiterator()
for el in iterator:
el.tail = None # save some memory el.tail = None # save some memory
else: else:
coverage_xml = None coverage_xml = None
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment