Sphinx: UnboundLocalError: local variable 'prefix' referenced before assignment

Created on 2 Apr 2017  Â·  6Comments  Â·  Source: sphinx-doc/sphinx

Problem

With the new version(1.5.4), sphinx-build fails for me with:

  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/sphinx/directives/__init__.py", line 163, in run
    self.before_content()
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/sphinx/domains/python.py", line 317, in before_content
    if prefix:
UnboundLocalError: local variable 'prefix' referenced before assignment

The full traceback:

....
   TemplateExportManager is responsible exporting images of type template.

   .. attribute:: See superclass




   .. py:attribute:: TemplateExportManager._abc_cache
      :module: lago.export
      :annotation: = <_weakrefset.WeakSet object at 0x42a9510>


   .. py:attribute:: TemplateExportManager._abc_negative_cache
      :module: lago.export
      :annotation: = <_weakrefset.WeakSet object at 0x42a9cd0>


   .. py:attribute:: TemplateExportManager._abc_negative_cache_version
      :module: lago.export
      :annotation: = 25


   .. py:attribute:: TemplateExportManager._abc_registry
      :module: lago.export
      :annotation: = <_weakrefset.WeakSet object at 0x42a9750>


   .. py:method:: TemplateExportManager.export()
      :module: lago.export

      See DiskExportManager.export


   .. py:method:: TemplateExportManager.rebase()
      :module: lago.export

      Change the backing-file entry of the exported disk.
      Please refer to 'qemu-img rebase' manual for more info.


   .. py:method:: TemplateExportManager.update_lago_metadata()
      :module: lago.export

[app] emitting event: 'build-finished'(UnboundLocalError("local variable 'prefix' referenced before assignment",),)

Traceback (most recent call last):
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/sphinx/cmdline.py", line 296, in main
    app.build(opts.force_all, filenames)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/sphinx/application.py", line 333, in build
    self.builder.build_update()
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/sphinx/builders/__init__.py", line 251, in build_update
    'out of date' % len(to_build))
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/sphinx/builders/__init__.py", line 265, in build
    self.doctreedir, self.app))
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/sphinx/environment/__init__.py", line 556, in update
    self._read_serial(docnames, app)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/sphinx/environment/__init__.py", line 576, in _read_serial
    self.read_doc(docname, app)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/sphinx/environment/__init__.py", line 684, in read_doc
    pub.publish()
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/core.py", line 217, in publish
    self.settings)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/sphinx/io.py", line 55, in read
    self.parse()
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/readers/__init__.py", line 78, in parse
    self.parser.parse(self.input, document)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/parsers/rst/__init__.py", line 185, in parse
    self.statemachine.run(inputlines, document, inliner=self.inliner)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 170, in run
    input_source=document['source'])
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/statemachine.py", line 239, in run
    context, state, transitions)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/statemachine.py", line 460, in check_line
    return method(match, context, next_state)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 2745, in underline
    self.section(title, source, style, lineno - 1, messages)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 326, in section
    self.new_subsection(title, lineno, messages)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 394, in new_subsection
    node=section_node, match_titles=True)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 281, in nested_parse
    node=node, match_titles=match_titles)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 195, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/statemachine.py", line 239, in run
    context, state, transitions)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/statemachine.py", line 460, in check_line
    return method(match, context, next_state)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 2745, in underline
    self.section(title, source, style, lineno - 1, messages)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 326, in section
    self.new_subsection(title, lineno, messages)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 394, in new_subsection
    node=section_node, match_titles=True)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 281, in nested_parse
    node=node, match_titles=match_titles)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 195, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/statemachine.py", line 239, in run
    context, state, transitions)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/statemachine.py", line 460, in check_line
    return method(match, context, next_state)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 2318, in explicit_markup
    nodelist, blank_finish = self.explicit_construct(match)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 2330, in explicit_construct
    return method(self, expmatch)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 2073, in directive
    directive_class, match, type_name, option_presets)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 2122, in run_directive
    result = directive_instance.run()
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/sphinx/ext/autodoc.py", line 1680, in run
    nested_parse_with_titles(self.state, self.result, node)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/sphinx/util/nodes.py", line 203, in nested_parse_with_titles
    return state.nested_parse(content, 0, node, match_titles=1)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 281, in nested_parse
    node=node, match_titles=match_titles)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 195, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/statemachine.py", line 239, in run
    context, state, transitions)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/statemachine.py", line 460, in check_line
    return method(match, context, next_state)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 2320, in explicit_markup
    self.explicit_list(blank_finish)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 2350, in explicit_list
    match_titles=self.state_machine.match_titles)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 318, in nested_list_parse
    node=node, match_titles=match_titles)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 195, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/statemachine.py", line 239, in run
    context, state, transitions)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/statemachine.py", line 460, in check_line
    return method(match, context, next_state)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 2623, in explicit_markup
    nodelist, blank_finish = self.explicit_construct(match)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 2330, in explicit_construct
    return method(self, expmatch)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 2073, in directive
    directive_class, match, type_name, option_presets)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 2122, in run_directive
    result = directive_instance.run()
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/sphinx/domains/__init__.py", line 199, in run
    return BaseDirective.run(self)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/sphinx/directives/__init__.py", line 164, in run
    self.state.nested_parse(self.content, self.content_offset, contentnode)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 281, in nested_parse
    node=node, match_titles=match_titles)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 195, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/statemachine.py", line 239, in run
    context, state, transitions)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/statemachine.py", line 460, in check_line
    return method(match, context, next_state)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 2318, in explicit_markup
    nodelist, blank_finish = self.explicit_construct(match)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 2330, in explicit_construct
    return method(self, expmatch)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 2073, in directive
    directive_class, match, type_name, option_presets)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 2122, in run_directive
    result = directive_instance.run()
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/sphinx/domains/__init__.py", line 199, in run
    return BaseDirective.run(self)
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/sphinx/directives/__init__.py", line 163, in run
    self.before_content()
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/sphinx/domains/python.py", line 317, in before_content
    if prefix:
UnboundLocalError: local variable 'prefix' referenced before assignment

Exception occurred:
  File "/home/ngoldin/src/nvgoldin.github.com/lago/tests/docs_venv/lib/python2.7/site-packages/sphinx/domains/python.py", line 317, in before_content
    if prefix:
UnboundLocalError: local variable 'prefix' referenced before assignment

Procedure to reproduce the problem

Did not isolate the issue yet. It worked before the new version was pushed.

Reproducible project / your project

Environment info

Most helpful comment

I will release it within a day. Please wait a moment.

All 6 comments

Sorry for inconvenience. I'll take a look.

Fixed at 57019c2.

It was caused by this notation:

   .. attribute:: See superclass

The py:attribute directive expects an argument is a name in python.
http://www.sphinx-doc.org/en/stable/domains.html#directive-py:attribute

The UnboundLocalError is raised when the argument is invalid name.

Will a release be happening soon, or should we pin for now?

I will release it within a day. Please wait a moment.

Thank you!

On Sun, Apr 2, 2017 at 11:01 AM, Takeshi KOMIYA notifications@github.com
wrote:

I will release it within a day. Please wait a moment.

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/sphinx-doc/sphinx/issues/3597#issuecomment-290991773,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAADBOjo0Ftb1DOL8IEtIM-Tu08BLhSnks5rr7g6gaJpZM4Mwxhw
.

--
"I disapprove of what you say, but I will defend to the death your right to
say it." -- Evelyn Beatrice Hall (summarizing Voltaire)
"The people's good is the highest law." -- Cicero
GPG Key fingerprint: D1B3 ADC0 E023 8CA6

@tk0miya - thanks for the quick response!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ubershmekel picture ubershmekel  Â·  3Comments

oonid picture oonid  Â·  3Comments

susmita1d picture susmita1d  Â·  3Comments

jfbu picture jfbu  Â·  3Comments

jessetan picture jessetan  Â·  3Comments