Commits

Georg Brandl committed 6a5de7d

Fix #611: latex writer raised IndexError on pages with no section but a link target.

  • Participants
  • Parent commits 9a945cf

Comments (0)

Files changed (1)

sphinx/writers/latex.py

                 next = node.parent[parindex+1]
             except IndexError:
                 # last node in parent, look at next after parent
-                # (for section of equal level)
-                next = node.parent.parent[node.parent.parent.index(node.parent)]
+                # (for section of equal level) if it exists
+                if node.parent.parent is not None:
+                    next = node.parent.parent[
+                        node.parent.parent.index(node.parent)]
+                else:
+                    raise
             if isinstance(next, nodes.section):
                 if node.get('refid'):
                     self.next_section_ids.add(node['refid'])