Skip to content

Commit bbada79

Browse files
committed
Avoid DeprecationWarnings for etree
Fixes Python-Markdown#618.
1 parent a7d211b commit bbada79

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

markdown/extensions/footnotes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def makeFootnotesDiv(self, root):
202202
)
203203
backlink.text = FN_BACKLINK_TEXT
204204

205-
if li.getchildren():
205+
if len(li):
206206
node = li[-1]
207207
if node.tag == "p":
208208
node.text = node.text + NBSP_PLACEHOLDER
@@ -393,7 +393,7 @@ def run(self, root):
393393
result = self.footnotes.findFootnotesPlaceholder(root)
394394
if result:
395395
child, parent, isText = result
396-
ind = parent.getchildren().index(child)
396+
ind = list(parent).index(child)
397397
if isText:
398398
parent.remove(child)
399399
parent.insert(ind, footnotesDiv)

markdown/treeprocessors.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,8 @@ def __applyPattern(self, pattern, data, patternIndex, startIndex=0):
272272
def __build_ancestors(self, parent, parents):
273273
"""Build the ancestor list."""
274274
ancestors = []
275-
while parent:
276-
if parent:
275+
while parent is not None:
276+
if parent is not None:
277277
ancestors.append(parent.tag.lower())
278278
parent = self.parent_map.get(parent)
279279
ancestors.reverse()
@@ -303,7 +303,7 @@ def run(self, tree, ancestors=None):
303303
# to ensure we don't have the user accidentally change it on us.
304304
tree_parents = [] if ancestors is None else ancestors[:]
305305

306-
self.parent_map = dict((c, p) for p in tree.getiterator() for c in p)
306+
self.parent_map = dict((c, p) for p in tree.iter() for c in p)
307307
stack = [(tree, tree_parents)]
308308

309309
while stack:

0 commit comments

Comments
 (0)