Merge branch 'fix-nonetype-error' into 'master'

Fix an issue when deleting subelements: TypeError: 'NoneType' object is not an iterator

See merge request poezio/slixmpp!39
This commit is contained in:
mathieui 2020-04-04 18:44:25 +02:00
commit 02202f7cd8

View file

@ -1031,13 +1031,18 @@ class ElementBase(object):
if not lang:
lang = default_lang
parent = self.xml
for level, _ in enumerate(path):
# Generate the paths to the target elements and their parent.
element_path = "/".join(path[:len(path) - level])
parent_path = "/".join(path[:len(path) - level - 1])
elements = self.xml.findall(element_path)
parent = self.xml.find(parent_path)
if parent_path == '':
parent_path = None
if parent_path is not None:
parent = self.xml.find(parent_path)
if elements:
if parent is None: