Skip to content

Commit

Permalink
Fix AttributeError on Python 3.9 due to usage of removed API in xml (#…
Browse files Browse the repository at this point in the history
…492)

* Fix usage of deprecated method on ElementTree or Element
These are covered by tests.

* Two more getchildren to just iteration (not covered by tests)
  • Loading branch information
kitchoi authored Dec 15, 2020
1 parent 77cb194 commit 030f067
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion enable/savage/compliance/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def addElementToTree(self, element, node):
node = self.AppendItem(node, txt)
self.SetPyData(node, element)
#children
for child in element.getchildren():
for child in element:
self.addElementToTree(child, node)
#attributes
for key, value in element.items():
Expand Down
6 changes: 3 additions & 3 deletions enable/savage/svg/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def findIDs(self, element, uri=''):
attribute it may be given.
"""
idmap = {}
for e in element.getiterator():
for e in element.iter():
id = e.get('id', None)
if id is not None:
idmap[(uri, id)] = e
Expand Down Expand Up @@ -468,7 +468,7 @@ def addGroupToDocument(self, node):
path = self.renderer.makePath()
ops.extend(self.createTransformOpsFromNode(node))
ops.extend(self.createTransformOpsFromXY(node))
for child in node.getchildren():
for child in node:
cpath, cops = self.processElement(child)
if cpath:
path.AddPath(cpath)
Expand Down Expand Up @@ -653,7 +653,7 @@ def addRectToDocument(self, node, path):
clip_path = self.renderer.makePath()
ops.extend(self.createTransformOpsFromNode(element))
ops.extend(self.generatePathOps(clip_path))
for child in element.getchildren():
for child in element:
cpath, cops = self.processElement(child)
if cpath:
clip_path.AddPath(cpath)
Expand Down
2 changes: 1 addition & 1 deletion kiva/tests/test_svg_drawing.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def draw_and_check(self):
filename = "{0}.svg".format(self.filename)
self.gc.save(filename)
tree = ElementTree.parse(filename)
elements = [element for element in tree.getiterator()]
elements = [element for element in tree.iter()]
if not len(elements) in [4, 7]:
self.fail('The expected number of elements was not found')

Expand Down

0 comments on commit 030f067

Please sign in to comment.