summaryrefslogtreecommitdiff
path: root/sphinx/transforms.py
diff options
context:
space:
mode:
authorDmitry Shachnev <mitya57@gmail.com>2016-01-22 18:14:04 +0300
committerDmitry Shachnev <mitya57@gmail.com>2016-01-22 18:14:04 +0300
commitc84dad28e9b1fa89b4c5bf61d48f39ba62335723 (patch)
treeee6d4e217d3d0e8600bc6ddbe21d14c8150123c0 /sphinx/transforms.py
parent1aeef288fc2f0760d4d74c43982873b7ec1243a9 (diff)
downloadsphinx-git-c84dad28e9b1fa89b4c5bf61d48f39ba62335723.tar.gz
transforms: Don't try to call has_child on parent nodes that are None
Otherwise the build can fail with the following error: File "/usr/lib/python2.7/dist-packages/sphinx/environment.py", line 791, in read_doc pub.publish() File "/usr/lib/python2.7/dist-packages/docutils/core.py", line 218, in publish self.apply_transforms() File "/usr/lib/python2.7/dist-packages/docutils/core.py", line 199, in apply_transforms self.document.transformer.apply_transforms() File "/usr/lib/python2.7/dist-packages/docutils/transforms/__init__.py", line 171, in apply_transforms transform.apply(**kwargs) File "/usr/lib/python2.7/dist-packages/sphinx/transforms.py", line 124, in apply if has_child(node.parent, nodes.caption): File "/usr/lib/python2.7/dist-packages/sphinx/transforms.py", line 117, in has_child return any(isinstance(child, cls) for child in node) TypeError: 'NoneType' object is not iterable The error could be reproduced with lp:autopilot/legacy branch from Launchpad.
Diffstat (limited to 'sphinx/transforms.py')
-rw-r--r--sphinx/transforms.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/sphinx/transforms.py b/sphinx/transforms.py
index 49c0aba1e..4619449e7 100644
--- a/sphinx/transforms.py
+++ b/sphinx/transforms.py
@@ -121,13 +121,13 @@ class AutoNumbering(Transform):
if has_child(node, nodes.caption):
self.document.note_implicit_target(node)
elif isinstance(node, nodes.image):
- if has_child(node.parent, nodes.caption):
+ if node.parent and has_child(node.parent, nodes.caption):
self.document.note_implicit_target(node.parent)
elif isinstance(node, nodes.table):
if has_child(node, nodes.title):
self.document.note_implicit_target(node)
elif isinstance(node, nodes.literal_block):
- if has_child(node.parent, nodes.caption):
+ if node.parent and has_child(node.parent, nodes.caption):
self.document.note_implicit_target(node.parent)