# Buggy code
def _parse(self):
    # type: () -> None
    self._parsed_lines = self._consume_empty()

    if self._name and (self._what == "attribute" or self._what == "data"):
        self._parsed_lines.extend(self._parse_attribute_docstring())
        return

    while self._line_iter.has_next():
        if self._is_section_header():
            try:
                section = self._consume_section_header()
                self._is_in_section = True
                self._section_indent = self._get_current_indent()
                if _directive_regex.match(section):  # type: ignore
                    lines = [section] + self._consume_to_next_section()
                else:
                    lines = self._sections[section.lower()](section)
            finally:
                self._is_in_section = False
                self._section_indent = 0
        else:
            if not self._parsed_lines:
                lines = self._consume_contiguous() + self._consume_empty()
            else:
                lines = self._consume_to_next_section()
        self._parsed_lines.extend(lines)


# Traceback (RuntimeError)
# Sphinx version: 1.7.5
# Python version: 3.7.0b5 (CPython)
# Docutils version: 0.14
# Jinja2 version: 2.10
# Last messages:
#   building [mo]: targets for 0 po files that are out of date
#
#   building [html]: targets for 10 source files that are out of date
#
#   updating environment:
#
#   10 added, 0 changed, 0 removed
#
#   reading sources... [ 10%] api
#
# Loaded extensions:
#   alabaster (0.7.10) from .../fedmsg/__venv37__/lib64/python3.7/site-packages/alabaster/__init__.py
#   sphinx.ext.autodoc (1.7.5) from .../fedmsg/__venv37__/lib64/python3.7/site-packages/sphinx/ext/autodoc/__init__.py
#   sphinx.ext.doctest (1.7.5) from .../fedmsg/__venv37__/lib64/python3.7/site-packages/sphinx/ext/doctest.py
#   sphinx.ext.intersphinx (1.7.5) from .../fedmsg/__venv37__/lib64/python3.7/site-packages/sphinx/ext/intersphinx.py
#   sphinx.ext.coverage (1.7.5) from .../fedmsg/__venv37__/lib64/python3.7/site-packages/sphinx/ext/coverage.py
#   sphinx.ext.viewcode (1.7.5) from .../fedmsg/__venv37__/lib64/python3.7/site-packages/sphinx/ext/viewcode.py
#   sphinx.ext.napoleon (1.7.5) from .../fedmsg/__venv37__/lib64/python3.7/site-packages/sphinx/ext/napoleon/__init__.py
Traceback (most recent call last):
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/sphinx/ext/autodoc/__init__.py", line 497, in process_doc
self.options, docstringlines)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/sphinx/application.py", line 444, in emit
return self.events.emit(event, self, *args)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/sphinx/events.py", line 79, in emit
results.append(callback(*args))
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/sphinx/ext/napoleon/__init__.py", line 367, in _process_docstring
obj, options)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/sphinx/ext/napoleon/docstring.py", line 885, in __init__
name, obj, options)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/sphinx/ext/napoleon/docstring.py", line 165, in __init__
self._parse()
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/sphinx/ext/napoleon/docstring.py", line 530, in _parse
self._parsed_lines.extend(self._parse_attribute_docstring())
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/sphinx/ext/napoleon/docstring.py", line 555, in _parse_attribute_docstring
_type, _desc = self._consume_inline_attribute()
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/sphinx/ext/napoleon/docstring.py", line 253, in _consume_inline_attribute
line = next(self._line_iter)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/sphinx/ext/napoleon/iterators.py", line 72, in __next__
return getattr(self, 'next')(n)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/sphinx/ext/napoleon/iterators.py", line 127, in next
raise StopIteration
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/sphinx/cmdline.py", line 304, in main
app.build(args.force_all, filenames)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/sphinx/application.py", line 331, in build
self.builder.build_update()
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/sphinx/builders/__init__.py", line 342, in build_update
'out of date' % len(to_build))
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/sphinx/builders/__init__.py", line 355, in build
updated_docnames = set(self.env.update(self.config, self.srcdir, self.doctreedir))
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/sphinx/environment/__init__.py", line 565, in update
self._read_serial(docnames, self.app)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/sphinx/environment/__init__.py", line 584, in _read_serial
self.read_doc(docname, app)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/sphinx/environment/__init__.py", line 659, in read_doc
doctree = read_doc(self.app, self, self.doc2path(docname))
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/sphinx/io.py", line 294, in read_doc
pub.publish()
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/docutils/core.py", line 217, in publish
self.settings)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/docutils/readers/__init__.py", line 72, in read
self.parse()
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/docutils/readers/__init__.py", line 78, in parse
self.parser.parse(self.input, document)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/sphinx/parsers.py", line 85, in parse
self.statemachine.run(inputstring, document, inliner=self.inliner)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/docutils/parsers/rst/states.py", line 171, in run
input_source=document['source'])
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/docutils/statemachine.py", line 239, in run
context, state, transitions)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/docutils/statemachine.py", line 460, in check_line
return method(match, context, next_state)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/docutils/parsers/rst/states.py", line 2988, in text
self.section(title.lstrip(), source, style, lineno + 1, messages)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/docutils/parsers/rst/states.py", line 327, in section
self.new_subsection(title, lineno, messages)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/docutils/parsers/rst/states.py", line 395, in new_subsection
node=section_node, match_titles=True)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/docutils/parsers/rst/states.py", line 282, in nested_parse
node=node, match_titles=match_titles)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/docutils/parsers/rst/states.py", line 196, in run
results = StateMachineWS.run(self, input_lines, input_offset)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/docutils/statemachine.py", line 239, in run
context, state, transitions)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/docutils/statemachine.py", line 460, in check_line
return method(match, context, next_state)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/docutils/parsers/rst/states.py", line 2753, in underline
self.section(title, source, style, lineno - 1, messages)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/docutils/parsers/rst/states.py", line 327, in section
self.new_subsection(title, lineno, messages)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/docutils/parsers/rst/states.py", line 395, in new_subsection
node=section_node, match_titles=True)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/docutils/parsers/rst/states.py", line 282, in nested_parse
node=node, match_titles=match_titles)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/docutils/parsers/rst/states.py", line 196, in run
results = StateMachineWS.run(self, input_lines, input_offset)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/docutils/statemachine.py", line 239, in run
context, state, transitions)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/docutils/statemachine.py", line 460, in check_line
return method(match, context, next_state)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/docutils/parsers/rst/states.py", line 2753, in underline
self.section(title, source, style, lineno - 1, messages)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/docutils/parsers/rst/states.py", line 327, in section
self.new_subsection(title, lineno, messages)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/docutils/parsers/rst/states.py", line 395, in new_subsection
node=section_node, match_titles=True)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/docutils/parsers/rst/states.py", line 282, in nested_parse
node=node, match_titles=match_titles)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/docutils/parsers/rst/states.py", line 196, in run
results = StateMachineWS.run(self, input_lines, input_offset)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/docutils/statemachine.py", line 239, in run
context, state, transitions)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/docutils/statemachine.py", line 460, in check_line
return method(match, context, next_state)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/docutils/parsers/rst/states.py", line 2328, in explicit_markup
self.explicit_list(blank_finish)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/docutils/parsers/rst/states.py", line 2358, in explicit_list
match_titles=self.state_machine.match_titles)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/docutils/parsers/rst/states.py", line 319, in nested_list_parse
node=node, match_titles=match_titles)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/docutils/parsers/rst/states.py", line 196, in run
results = StateMachineWS.run(self, input_lines, input_offset)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/docutils/statemachine.py", line 239, in run
context, state, transitions)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/docutils/statemachine.py", line 460, in check_line
return method(match, context, next_state)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/docutils/parsers/rst/states.py", line 2631, in explicit_markup
nodelist, blank_finish = self.explicit_construct(match)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/docutils/parsers/rst/states.py", line 2338, in explicit_construct
return method(self, expmatch)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/docutils/parsers/rst/states.py", line 2081, in directive
directive_class, match, type_name, option_presets)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/docutils/parsers/rst/states.py", line 2130, in run_directive
result = directive_instance.run()
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/sphinx/ext/autodoc/directive.py", line 133, in run
documenter.generate(more_content=self.content)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/sphinx/ext/autodoc/__init__.py", line 796, in generate
self.add_content(more_content)
File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/sphinx/ext/autodoc/__init__.py", line 537, in add_content
for i, line in enumerate(self.process_doc(docstrings)):
RuntimeError: generator raised StopIteration

# Fixed code
def _parse(self):
    # type: () -> None
    self._parsed_lines = self._consume_empty()

    if self._name and (self._what == "attribute" or self._what == "data"):
        # Implicit stop using StopIteration no longer allowed in
        # Python 3.7; see PEP 479
        res = []  # type: List[unicode]
        try:
            res = self._parse_attribute_docstring()
        except StopIteration:
            pass
        self._parsed_lines.extend(res)
        return

    while self._line_iter.has_next():
        if self._is_section_header():
            try:
                section = self._consume_section_header()
                self._is_in_section = True
                self._section_indent = self._get_current_indent()
                if _directive_regex.match(section):  # type: ignore
                    lines = [section] + self._consume_to_next_section()
                else:
                    lines = self._sections[section.lower()](section)
            finally:
                self._is_in_section = False
                self._section_indent = 0
        else:
            if not self._parsed_lines:
                lines = self._consume_contiguous() + self._consume_empty()
            else:
                lines = self._consume_to_next_section()
        self._parsed_lines.extend(lines)