summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiro Hrončok <miro@hroncok.cz>2020-01-06 14:05:03 +0100
committerMiro Hrončok <miro@hroncok.cz>2020-01-06 14:05:03 +0100
commit1f9284228092b2a7200e8a78bc0ea6702231c6db (patch)
tree79fb16a0fbcffc1ae0a88118d9f1ff0b70203e15
parent284b4c828a84a776233fc21438640d974c52394d (diff)
downloadgobject-introspection-1f9284228092b2a7200e8a78bc0ea6702231c6db.tar.gz
Drop deprecated xml.etree.ElementTree.Element.getchildren() calls
The XML elements are implicitly iterable in all Python versions including at least 2.7 and 3.2+. The .getchildren() method is deprecated since 2.7 and 3.2, removed in 3.9. Fixes https://gitlab.gnome.org/GNOME/gobject-introspection/issues/325
-rw-r--r--giscanner/girparser.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/giscanner/girparser.py b/giscanner/girparser.py
index 7687c35c..0a6c687b 100644
--- a/giscanner/girparser.py
+++ b/giscanner/girparser.py
@@ -75,17 +75,17 @@ class GIRParser(object):
def _find_first_child(self, node, name_or_names):
if isinstance(name_or_names, str):
- for child in node.getchildren():
+ for child in node:
if child.tag == name_or_names:
return child
else:
- for child in node.getchildren():
+ for child in node:
if child.tag in name_or_names:
return child
return None
def _find_children(self, node, name):
- return [child for child in node.getchildren() if child.tag == name]
+ return [child for child in node if child.tag == name]
def _get_current_file(self):
if not self._filename_stack:
@@ -103,7 +103,7 @@ class GIRParser(object):
raise SystemExit("%s: Incompatible version %s (supported: %s)" %
(self._get_current_file(), version, COMPATIBLE_GIR_VERSION))
- for node in root.getchildren():
+ for node in root:
if node.tag == _corens('include'):
self._parse_include(node)
elif node.tag == _corens('package'):
@@ -145,7 +145,7 @@ class GIRParser(object):
parser_methods[_corens('function-macro')] = self._parse_function_macro
parser_methods[_corens('function')] = self._parse_function
- for node in ns.getchildren():
+ for node in ns:
method = parser_methods.get(node.tag)
if method is not None:
method(node)
@@ -413,7 +413,7 @@ class GIRParser(object):
def _parse_fields(self, node, obj):
res = []
names = (_corens('field'), _corens('record'), _corens('union'), _corens('callback'))
- for child in node.getchildren():
+ for child in node:
if child.tag in names:
fieldobj = self._parse_field(child, obj)
res.append(fieldobj)