Fix TypeError: 'NoneType' object is not an iterator
When deleting sub-elements in a stanza.
This commit is contained in:
parent
98108d0445
commit
2add94f5b0
@ -1031,14 +1031,19 @@ class ElementBase(object):
|
|||||||
if not lang:
|
if not lang:
|
||||||
lang = default_lang
|
lang = default_lang
|
||||||
|
|
||||||
|
parent = self.xml
|
||||||
for level, _ in enumerate(path):
|
for level, _ in enumerate(path):
|
||||||
# Generate the paths to the target elements and their parent.
|
# Generate the paths to the target elements and their parent.
|
||||||
element_path = "/".join(path[:len(path) - level])
|
element_path = "/".join(path[:len(path) - level])
|
||||||
parent_path = "/".join(path[:len(path) - level - 1])
|
parent_path = "/".join(path[:len(path) - level - 1])
|
||||||
|
|
||||||
elements = self.xml.findall(element_path)
|
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 elements:
|
||||||
if parent is None:
|
if parent is None:
|
||||||
parent = self.xml
|
parent = self.xml
|
||||||
|
Loading…
Reference in New Issue
Block a user