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

This commit is contained in:
Georg Brandl
2011-11-01 09:09:50 +01:00
parent 5d19b860e2
commit 90b7372b80
2 changed files with 14 additions and 2 deletions

View File

@@ -1,6 +1,8 @@
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.

View File

@@ -259,13 +259,23 @@ class Glossary(Directive):
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