From bbada79726d900ef9ae5410ab3a0ce573a742c00 Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Thu, 4 Jan 2018 14:24:30 -0500 Subject: Avoid DeprecationWarnings for etree Fixes #618. --- markdown/extensions/footnotes.py | 4 ++-- markdown/treeprocessors.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/markdown/extensions/footnotes.py b/markdown/extensions/footnotes.py index 620cf0b..cdaf391 100644 --- a/markdown/extensions/footnotes.py +++ b/markdown/extensions/footnotes.py @@ -202,7 +202,7 @@ class FootnoteExtension(Extension): ) backlink.text = FN_BACKLINK_TEXT - if li.getchildren(): + if len(li): node = li[-1] if node.tag == "p": node.text = node.text + NBSP_PLACEHOLDER @@ -393,7 +393,7 @@ class FootnoteTreeprocessor(Treeprocessor): result = self.footnotes.findFootnotesPlaceholder(root) if result: child, parent, isText = result - ind = parent.getchildren().index(child) + ind = list(parent).index(child) if isText: parent.remove(child) parent.insert(ind, footnotesDiv) diff --git a/markdown/treeprocessors.py b/markdown/treeprocessors.py index f159a8a..8feea8d 100644 --- a/markdown/treeprocessors.py +++ b/markdown/treeprocessors.py @@ -272,8 +272,8 @@ class InlineProcessor(Treeprocessor): def __build_ancestors(self, parent, parents): """Build the ancestor list.""" ancestors = [] - while parent: - if parent: + while parent is not None: + if parent is not None: ancestors.append(parent.tag.lower()) parent = self.parent_map.get(parent) ancestors.reverse() @@ -303,7 +303,7 @@ class InlineProcessor(Treeprocessor): # to ensure we don't have the user accidentally change it on us. tree_parents = [] if ancestors is None else ancestors[:] - self.parent_map = dict((c, p) for p in tree.getiterator() for c in p) + self.parent_map = dict((c, p) for p in tree.iter() for c in p) stack = [(tree, tree_parents)] while stack: -- cgit v1.2.3