Georg Brandl avatar Georg Brandl committed df1afa5

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

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.

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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.