Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/sphinx-doc/sphinx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2021-10-26 19:49:57 +0300
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2021-10-26 19:49:59 +0300
commit13803a79e7179f40a27f46d5a5a05f1eebbcbb63 (patch)
tree2cb19dd2900c96c57f601d46bdfbfc0652127b13 /sphinx/util
parent2be9d6b092965a2f9354da66b645bf5ea76ce288 (diff)
Support docutils-0.18: Consume iterator of Element.traverse()
Since 0.18, Element.traverse() returns an iterator instead of intermediate object. As a result, the return value is always considered as truthy value. And it becomes fragile when the caller modifies the doctree on the loop.
Diffstat (limited to 'sphinx/util')
-rw-r--r--sphinx/util/nodes.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/sphinx/util/nodes.py b/sphinx/util/nodes.py
index 78663e4c7..bc16e44c1 100644
--- a/sphinx/util/nodes.py
+++ b/sphinx/util/nodes.py
@@ -343,7 +343,7 @@ def clean_astext(node: Element) -> str:
node = node.deepcopy()
for img in node.traverse(nodes.image):
img['alt'] = ''
- for raw in node.traverse(nodes.raw):
+ for raw in list(node.traverse(nodes.raw)):
raw.parent.remove(raw)
return node.astext()
@@ -408,7 +408,7 @@ def inline_all_toctrees(builder: "Builder", docnameset: Set[str], docname: str,
Record all docnames in *docnameset*, and output docnames with *colorfunc*.
"""
tree = cast(nodes.document, tree.deepcopy())
- for toctreenode in tree.traverse(addnodes.toctree):
+ for toctreenode in list(tree.traverse(addnodes.toctree)):
newnodes = []
includefiles = map(str, toctreenode['includefiles'])
for includefile in includefiles: