Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.7 failures in sphinx/ext/napoleon/iterators.py: RuntimeError: generator raised StopIteration #5076

Closed
hroncok opened this issue Jun 11, 2018 · 6 comments

Comments

@hroncok
Copy link
Contributor

hroncok commented Jun 11, 2018

Problem

Building docs for fedmsg in Fedora with Python 3.7:

Exception occurred:
  File "/usr/lib/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
The full traceback has been saved in /tmp/sphinx-err-bymahz8r.log, if you want to report the issue to the developers.

Full log: build.log.gz

Procedure to reproduce the problem

$ git clone [email protected]:fedora-infra/fedmsg.git && cd fedmsg/  # at 3854e4c
[fedmsg (develop)]$ python3.7 -m venv __venv37__
[fedmsg (develop)]$ . __venv37__/bin/activate
(__venv37__) [fedmsg (develop)]$ pip install -e. sphinx psutil moksha.hub
(__venv37__) [doc (develop)]$ cd doc/
(__venv37__) [doc (develop)]$ make html
...
Exception occurred:
  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

Error logs / results

# 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

Expected results

The generator should return instead.

Reproducible project / your project

Environment info

  • OS: Linux (Fedora 28, 29)
  • Python version: 3.7.0b5
  • Sphinx version: 1.7.5
@hroncok
Copy link
Contributor Author

hroncok commented Jun 11, 2018

BTW even if I replace raise StopIterations with returns, I get:

# 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/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)):
  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 254, in _consume_inline_attribute
    _type, colon, _desc = self._partition_field_on_colon(line)
  File ".../fedmsg/__venv37__/lib64/python3.7/site-packages/sphinx/ext/napoleon/docstring.py", line 749, in _partition_field_on_colon
    for i, source in enumerate(_xref_regex.split(line)):  # type: ignore
TypeError: expected string or bytes-like object

@tk0miya
Copy link
Member

tk0miya commented Jun 19, 2018

Note: Reproduced with 3.7.0b5.

# Dockerfile
FROM python:3.7.0b5

RUN git clone https://github.com/fedora-infra/fedmsg
RUN pip3 install -U pip setuptools tox
WORKDIR /fedmsg
RUN tox -e docs

But this is not raised with 3.6.5

# Dockefile
FROM python:3.6.5

RUN git clone https://github.com/fedora-infra/fedmsg
RUN pip3 install -U pip setuptools tox
WORKDIR /fedmsg
RUN tox -e docs

@tk0miya
Copy link
Member

tk0miya commented Jun 20, 2018

In my short investigation, this bug comes from PEP-479.
https://www.python.org/dev/peps/pep-0479/

Certainly, napoleon throws StopIteration if empty docstring given. It seems this behavior is conflicted with the change of PEP-479.

$ python
Python 2.7.15 (default, May  1 2018, 22:52:16)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from sphinx.ext.napoleon.docstring import GoogleDocstring
>>> GoogleDocstring([], what='data', name='name')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "sphinx/ext/napoleon/docstring.py", line 165, in __init__
    self._parse()
  File "sphinx/ext/napoleon/docstring.py", line 530, in _parse
    self._parsed_lines.extend(self._parse_attribute_docstring())
  File "sphinx/ext/napoleon/docstring.py", line 555, in _parse_attribute_docstring
    _type, _desc = self._consume_inline_attribute()
  File "sphinx/ext/napoleon/docstring.py", line 253, in _consume_inline_attribute
    line = next(self._line_iter)
  File "sphinx/ext/napoleon/iterators.py", line 127, in next
    raise StopIteration
StopIteration

@RobRuana Could you check this please?

@hroncok
Copy link
Contributor Author

hroncok commented Jun 20, 2018

That is related. But see also #5076 (comment)

michel-slm added a commit to michel-slm/sphinx that referenced this issue Jun 25, 2018
Per PEP 479, Python 3.7 no longer allows bubbling up StopIteration
outside of a generator. Instead, wrap attribute parsing in a try
block and provide a sane default in case it raises an exception
([]).
RobRuana pushed a commit that referenced this issue Jul 3, 2018
* Closes #5076: [ext/napoleon] explicitly catch StopIteration

Per PEP 479, Python 3.7 no longer allows bubbling up StopIteration
outside of a generator. Instead, wrap attribute parsing in a try
block and provide a sane default in case it raises an exception
([]).

* Fix mypy and flake8 issues
@Tryph
Copy link

Tryph commented Jul 6, 2018

I noted this problem too.

Problem

For my project, doc generation is run by Gitlab CI into the a python:3 docker container. Two days ago, it started failing with the following message:

Exception occurred:
  File "/usr/local/lib/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
The full traceback has been saved in /tmp/sphinx-err-tf2avyed.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!
Makefile:20: recipe for target 'html' failed

Two days ago, the docker image python:3.7 has became the target of the python:3 tag and restricting used python image to 3.6 fixed my problem.

Procedure to reproduce the problem

Run make html for an autodoc umented project inside a python:3.7 docker container.

Error logs / results

Below is the content of the /tmp/sphinx-err-tf2avyed.log file:

# Sphinx version: 1.7.5
# Python version: 3.7.0 (CPython)
# Docutils version: 0.14 
# Jinja2 version: 2.10
# Last messages:
#   reading sources... [ 14%] index
#   
#   reading sources... [ 28%] technic/code_reference/api
#   
#   reading sources... [ 42%] technic/code_reference/app
#   
#   reading sources... [ 57%] technic/code_reference/common
#   
#   reading sources... [ 71%] technic/code_reference/db
#   
# Loaded extensions:
#   alabaster (0.7.11) from /usr/local/lib/python3.7/site-packages/alabaster/__init__.py
#   sphinx.ext.autodoc (1.7.5) from /usr/local/lib/python3.7/site-packages/sphinx/ext/autodoc/__init__.py
#   sphinx.ext.intersphinx (1.7.5) from /usr/local/lib/python3.7/site-packages/sphinx/ext/intersphinx.py
#   sphinx.ext.todo (1.7.5) from /usr/local/lib/python3.7/site-packages/sphinx/ext/todo.py
#   sphinx.ext.coverage (1.7.5) from /usr/local/lib/python3.7/site-packages/sphinx/ext/coverage.py
#   sphinx.ext.viewcode (1.7.5) from /usr/local/lib/python3.7/site-packages/sphinx/ext/viewcode.py
#   sphinx.ext.napoleon (1.7.5) from /usr/local/lib/python3.7/site-packages/sphinx/ext/napoleon/__init__.py
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/sphinx/ext/autodoc/__init__.py", line 497, in process_doc
    self.options, docstringlines)
  File "/usr/local/lib/python3.7/site-packages/sphinx/application.py", line 444, in emit
    return self.events.emit(event, self, *args)
  File "/usr/local/lib/python3.7/site-packages/sphinx/events.py", line 79, in emit
    results.append(callback(*args))
  File "/usr/local/lib/python3.7/site-packages/sphinx/ext/napoleon/__init__.py", line 367, in _process_docstring
    obj, options)
  File "/usr/local/lib/python3.7/site-packages/sphinx/ext/napoleon/docstring.py", line 885, in __init__
    name, obj, options)
  File "/usr/local/lib/python3.7/site-packages/sphinx/ext/napoleon/docstring.py", line 165, in __init__
    self._parse()
  File "/usr/local/lib/python3.7/site-packages/sphinx/ext/napoleon/docstring.py", line 530, in _parse
    self._parsed_lines.extend(self._parse_attribute_docstring())
  File "/usr/local/lib/python3.7/site-packages/sphinx/ext/napoleon/docstring.py", line 555, in _parse_attribute_docstring
    _type, _desc = self._consume_inline_attribute()
  File "/usr/local/lib/python3.7/site-packages/sphinx/ext/napoleon/docstring.py", line 253, in _consume_inline_attribute
    line = next(self._line_iter)
  File "/usr/local/lib/python3.7/site-packages/sphinx/ext/napoleon/iterators.py", line 72, in __next__
    return getattr(self, 'next')(n)
  File "/usr/local/lib/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 "/usr/local/lib/python3.7/site-packages/sphinx/cmdline.py", line 304, in main
    app.build(args.force_all, filenames)
  File "/usr/local/lib/python3.7/site-packages/sphinx/application.py", line 331, in build
    self.builder.build_update()
  File "/usr/local/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 342, in build_update
    'out of date' % len(to_build))
  File "/usr/local/lib/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 "/usr/local/lib/python3.7/site-packages/sphinx/environment/__init__.py", line 565, in update
    self._read_serial(docnames, self.app)
  File "/usr/local/lib/python3.7/site-packages/sphinx/environment/__init__.py", line 584, in _read_serial
    self.read_doc(docname, app)
  File "/usr/local/lib/python3.7/site-packages/sphinx/environment/__init__.py", line 659, in read_doc
    doctree = read_doc(self.app, self, self.doc2path(docname))
  File "/usr/local/lib/python3.7/site-packages/sphinx/io.py", line 294, in read_doc
    pub.publish()
  File "/usr/local/lib/python3.7/site-packages/docutils/core.py", line 217, in publish
    self.settings)
  File "/usr/local/lib/python3.7/site-packages/docutils/readers/__init__.py", line 72, in read
    self.parse()
  File "/usr/local/lib/python3.7/site-packages/docutils/readers/__init__.py", line 78, in parse
    self.parser.parse(self.input, document)
  File "/usr/local/lib/python3.7/site-packages/sphinx/parsers.py", line 85, in parse
    self.statemachine.run(inputstring, document, inliner=self.inliner)
  File "/usr/local/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 171, in run
    input_source=document['source'])
  File "/usr/local/lib/python3.7/site-packages/docutils/statemachine.py", line 239, in run
    context, state, transitions)
  File "/usr/local/lib/python3.7/site-packages/docutils/statemachine.py", line 460, in check_line
    return method(match, context, next_state)
  File "/usr/local/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 2753, in underline
    self.section(title, source, style, lineno - 1, messages)
  File "/usr/local/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 327, in section
    self.new_subsection(title, lineno, messages)
  File "/usr/local/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 395, in new_subsection
    node=section_node, match_titles=True)
  File "/usr/local/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 282, in nested_parse
    node=node, match_titles=match_titles)
  File "/usr/local/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 196, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/usr/local/lib/python3.7/site-packages/docutils/statemachine.py", line 239, in run
    context, state, transitions)
  File "/usr/local/lib/python3.7/site-packages/docutils/statemachine.py", line 460, in check_line
    return method(match, context, next_state)
  File "/usr/local/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 2753, in underline
    self.section(title, source, style, lineno - 1, messages)
  File "/usr/local/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 327, in section
    self.new_subsection(title, lineno, messages)
  File "/usr/local/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 395, in new_subsection
    node=section_node, match_titles=True)
  File "/usr/local/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 282, in nested_parse
    node=node, match_titles=match_titles)
  File "/usr/local/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 196, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/usr/local/lib/python3.7/site-packages/docutils/statemachine.py", line 239, in run
    context, state, transitions)
  File "/usr/local/lib/python3.7/site-packages/docutils/statemachine.py", line 460, in check_line
    return method(match, context, next_state)
  File "/usr/local/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 2326, in explicit_markup
    nodelist, blank_finish = self.explicit_construct(match)
  File "/usr/local/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 2338, in explicit_construct
    return method(self, expmatch)
  File "/usr/local/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 2081, in directive
    directive_class, match, type_name, option_presets)
  File "/usr/local/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 2130, in run_directive
    result = directive_instance.run()
  File "/usr/local/lib/python3.7/site-packages/sphinx/ext/autodoc/directive.py", line 133, in run
    documenter.generate(more_content=self.content)
  File "/usr/local/lib/python3.7/site-packages/sphinx/ext/autodoc/__init__.py", line 799, in generate
    self.document_members(all_members)
  File "/usr/local/lib/python3.7/site-packages/sphinx/ext/autodoc/__init__.py", line 720, in document_members
    check_module=members_check_module and not isattr)
  File "/usr/local/lib/python3.7/site-packages/sphinx/ext/autodoc/__init__.py", line 1211, in generate
    all_members=all_members)
  File "/usr/local/lib/python3.7/site-packages/sphinx/ext/autodoc/__init__.py", line 799, in generate
    self.document_members(all_members)
  File "/usr/local/lib/python3.7/site-packages/sphinx/ext/autodoc/__init__.py", line 1200, in document_members
    ModuleLevelDocumenter.document_members(self, all_members)
  File "/usr/local/lib/python3.7/site-packages/sphinx/ext/autodoc/__init__.py", line 720, in document_members
    check_module=members_check_module and not isattr)
  File "/usr/local/lib/python3.7/site-packages/sphinx/ext/autodoc/__init__.py", line 796, in generate
    self.add_content(more_content)
  File "/usr/local/lib/python3.7/site-packages/sphinx/ext/autodoc/__init__.py", line 1402, in add_content
    ClassLevelDocumenter.add_content(self, more_content, no_docstring)
  File "/usr/local/lib/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

Environment info

  • OS: Python:3.7 docker container on a Debian 8.10 host
  • Python version: 3.7
  • Sphinx version: 1.7.5
  • extra-tools:
    • alabaster==0.7.11
    • sphinx-rtd-theme==0.4.0
    • sphinxcontrib-websupport==1.1.0

@tk0miya
Copy link
Member

tk0miya commented Jul 9, 2018

Fixed by #5119.
Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants