Fix use of deprecated function in xml module.

pull/63538/head
Matt Clay 5 years ago
parent 32b57d57a0
commit d829a50a5b

@ -0,0 +1,2 @@
bugfixes:
- Fix the ``xml`` module to use ``list(elem)`` instead of ``elem.getchildren()`` since it is being removed in Python 3.9

@ -441,7 +441,7 @@ def delete_xpath_target(module, tree, xpath, namespaces):
def replace_children_of(children, match):
for element in match.getchildren():
for element in list(match):
match.remove(element)
match.extend(children)
@ -458,8 +458,8 @@ def set_target_children_inner(module, tree, xpath, namespaces, children, in_type
# xpaths always return matches as a list, so....
for match in matches:
# Check if elements differ
if len(match.getchildren()) == len(children):
for idx, element in enumerate(match.getchildren()):
if len(list(match)) == len(children):
for idx, element in enumerate(list(match)):
if etree.tostring(element) != children_as_string[idx]:
replace_children_of(children, match)
changed = True

Loading…
Cancel
Save