Commits

Georg Brandl committed df1afa5

Closes #797: Don't crash on a misformatted glossary.

  • Participants
  • Parent commits b656047
  • Branches stable

Comments (0)

Files changed (2)

 Release 1.1.1 (in development)
 ==============================
 
+* #797: Don't crash on a misformatted glossary.
+
 * #801: Make intersphinx work properly without SSL support.
 
 * #805: Make the ``Sphinx.add_index_to_domain`` method work correctly.

File sphinx/domains/std.py

                         messages.append(self.state.reporter.system_message(
                             2, 'glossary terms must not be separated by empty '
                             'lines', source=source, line=lineno))
-                    entries[-1][0].append((line, source, lineno))
+                    if entries:
+                        entries[-1][0].append((line, source, lineno))
+                    else:
+                        messages.append(self.state.reporter.system_message(
+                            2, 'glossary seems to be misformatted, check '
+                        'indentation', source=source, line=lineno))
             else:
                 if not in_definition:
                     # first line of definition, determines indentation
                     in_definition = True
                     indent_len = len(line) - len(line.lstrip())
-                entries[-1][1].append(line[indent_len:], source, lineno)
+                if entries:
+                    entries[-1][1].append(line[indent_len:], source, lineno)
+                else:
+                    messages.append(self.state.reporter.system_message(
+                        2, 'glossary seems to be misformatted, check '
+                    'indentation', source=source, line=lineno))
             was_empty = False
 
         # now, parse all the entries into a big definition list