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)