Skip to content

Sphinx 5.1.0 exception: pop from an empty deque #10701

Closed
spack/spack
#31756
@eivindjahren

Description

@eivindjahren

Describe the bug

As of 5.1.0 our doc build at github.com/equinor/ert stopped working and gives us the following unhandled exception:

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/sphinx/events.py", line 94, in emit
    results.append(listener.handler(self.app, *args))
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/sphinx/ext/napoleon/__init__.py", line 385, in _process_docstring
    docstring = NumpyDocstring(result_lines, app.config, app, what, name,
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/sphinx/ext/napoleon/docstring.py", line 1147, in __init__
    super().__init__(docstring, config, app, what, name, obj, options)
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/sphinx/ext/napoleon/docstring.py", line 214, in __init__
    self._parse()
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/sphinx/ext/napoleon/docstring.py", line 594, in _parse
    res = self._parse_attribute_docstring()
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/sphinx/ext/napoleon/docstring.py", line 626, in _parse_attribute_docstring
    _type, _desc = self._consume_inline_attribute()
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/sphinx/ext/napoleon/docstring.py", line 303, in _consume_inline_attribute
    line = self._lines.popleft()
IndexError: pop from an empty deque
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/sphinx/cmd/build.py", line [27](https://github.com/equinor/ert/runs/7488615143?check_suite_focus=true#step:8:28)7, in build_main
    app.build(args.force_all, filenames)
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/sphinx/application.py", line 349, in build
    self.builder.build_update()
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/sphinx/builders/__init__.py", line 300, in build_update
    self.build(to_build,
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/sphinx/builders/__init__.py", line 316, in build
    updated_docnames = set(self.read())
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/sphinx/builders/__init__.py", line 423, in read
    self._read_serial(docnames)
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/sphinx/builders/__init__.py", line 444, in _read_serial
    self.read_doc(docname)
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/sphinx/builders/__init__.py", line 497, in read_doc
    publisher.publish()
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/docutils/core.py", line 217, in publish
    self.document = self.reader.read(self.source, self.parser,
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/sphinx/io.py", line 104, in read
    self.parse()
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/docutils/readers/__init__.py", line 78, in parse
    self.parser.parse(self.input, document)
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/sphinx/parsers.py", line 78, in parse
    self.statemachine.run(inputlines, document, inliner=self.inliner)
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 170, in run
    results = StateMachineWS.run(self, input_lines, input_offset,
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/docutils/statemachine.py", line 239, in run
    context, next_state, result = self.check_line(
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/docutils/statemachine.py", line 451, in check_line
    return method(match, context, next_state)
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 2769, in underline
    self.section(title, source, style, lineno - 1, messages)
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 327, in section
    self.new_subsection(title, lineno, messages)
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 393, in new_subsection
    newabsoffset = self.nested_parse(
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line [28](https://github.com/equinor/ert/runs/7488615143?check_suite_focus=true#step:8:29)1, in nested_parse
    state_machine.run(block, input_offset, memo=self.memo,
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 196, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/docutils/statemachine.py", line 239, in run
    context, next_state, result = self.check_line(
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/docutils/statemachine.py", line 451, in check_line
    return method(match, context, next_state)
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 2344, in explicit_markup
    self.explicit_list(blank_finish)
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 2369, in explicit_list
    newline_offset, blank_finish = self.nested_list_parse(
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 318, in nested_list_parse
    state_machine.run(block, input_offset, memo=self.memo,
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 196, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/docutils/statemachine.py", line 239, in run
    context, next_state, result = self.check_line(
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/docutils/statemachine.py", line 451, in check_line
    return method(match, context, next_state)
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 2647, in explicit_markup
    nodelist, blank_finish = self.explicit_construct(match)
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 2354, in explicit_construct
    return method(self, expmatch)
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 2096, in directive
    return self.run_directive(
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 2146, in run_directive
    result = directive_instance.run()
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/sphinx/ext/autodoc/directive.py", line 148, in run
    documenter.generate(more_content=self.content)
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/sphinx/ext/autodoc/__init__.py", line 1788, in generate
    return super().generate(more_content=more_content,
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/sphinx/ext/autodoc/__init__.py", line 954, in generate
    self.document_members(all_members)
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/sphinx/ext/autodoc/__init__.py", line 1779, in document_members
    super().document_members(all_members)
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/sphinx/ext/autodoc/__init__.py", line 8[30](https://github.com/equinor/ert/runs/7488615143?check_suite_focus=true#step:8:31), in document_members
    documenter.generate(
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/sphinx/ext/autodoc/__init__.py", line 951, in generate
    self.add_content(more_content)
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/sphinx/ext/autodoc/__init__.py", line 602, in add_content
    for i, line in enumerate(self.process_doc(docstrings)):
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/sphinx/ext/autodoc/__init__.py", line 547, in process_doc
    self.env.app.emit('autodoc-process-docstring',
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/sphinx/application.py", line [46](https://github.com/equinor/ert/runs/7488615143?check_suite_focus=true#step:8:47)0, in emit
    return self.events.emit(event, *args, allowed_exceptions=allowed_exceptions)
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/sphinx/events.py", line 105, in emit
    raise ExtensionError(__("Handler %r for event %r threw an exception") %
sphinx.errors.ExtensionError: Handler <function _process_docstring at 0x7fe6a9[57](https://github.com/equinor/ert/runs/7488615143?check_suite_focus=true#step:8:58)2280> for event 'autodoc-process-docstring' threw an exception (exception: pop from an empty deque)
Extension error (sphinx.ext.napoleon):
Handler <function _process_docstring at 0x7fe6a95[72](https://github.com/equinor/ert/runs/7488615143?check_suite_focus=true#step:8:73)2[80](https://github.com/equinor/ert/runs/7488615143?check_suite_focus=true#step:8:81)> for event 'autodoc-process-docstring' threw an exception (exception: pop from an empty deque)
Error: Process completed with exit code 2.

How to Reproduce

Following works in my environment, if there are issues, see https://github.com/equinor/ert/blob/ec015e87ef511f45826ae53c0aae1d6e1a99b9f1/.github/workflows/build.yml#L195 for how its
done in CI.

$ git clone https://github.com/equinor/ert
$ cd ert
$ pip install .
$ pip install -r dev_requirements.txt
$ sphinx-build -n -v -E -W ./docs/rst/manual ./tmp/ert_docs

Expected behavior

Documentation is built

Your project

github.com/equinor/ert

Screenshots

No response

OS

Ubuntu-latest

Python version

3.8

Sphinx version

5.1.0

Sphinx extensions

"sphinx.ext.intersphinx", "sphinx.ext.mathjax", "sphinx.ext.ifconfig", "sphinx.ext.githubpages", "sphinx.ext.autodoc", "sphinx.ext.napoleon", "sphinxarg.ext", "sphinx.ext.todo", "sphinxcontrib.datatemplates",

Extra tools

No response

Additional context

Our project uses some custom plugins, and we are trying to figure out if they are acting up.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions