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

'NoneType' object has no attribute '__dict__' #17

Open
njsmith opened this issue Aug 11, 2018 · 0 comments
Open

'NoneType' object has no attribute '__dict__' #17

njsmith opened this issue Aug 11, 2018 · 0 comments

Comments

@njsmith
Copy link
Member

njsmith commented Aug 11, 2018

@thmo reported this crash when building the pytest docs (apparently they use sphinxcontrib-trio now, I had no idea :-)):

# Sphinx version: 1.7.5
# Python version: 3.6.6 (CPython)
# Docutils version: 0.14 
# Jinja2 version: 2.10
# Last messages:
#   reading sources... [ 89%] projects
#   
#   reading sources... [ 90%] proposals/parametrize_with_fixtures
#   
#   reading sources... [ 91%] pythonpath
#   
#   reading sources... [ 92%] recwarn
#   
#   reading sources... [ 92%] reference
#   
# Loaded extensions:
#   alabaster (0.7.9) from /usr/lib/python3.6/site-packages/alabaster/__init__.py
#   sphinx.ext.autodoc (1.7.5) from /usr/lib/python3.6/site-packages/sphinx/ext/autodoc/__init__.py
#   sphinx.ext.todo (1.7.5) from /usr/lib/python3.6/site-packages/sphinx/ext/todo.py
#   sphinx.ext.autosummary (1.7.5) from /usr/lib/python3.6/site-packages/sphinx/ext/autosummary/__init__.py
#   sphinx.ext.intersphinx (1.7.5) from /usr/lib/python3.6/site-packages/sphinx/ext/intersphinx.py
#   sphinx.ext.viewcode (1.7.5) from /usr/lib/python3.6/site-packages/sphinx/ext/viewcode.py
#   sphinxcontrib_trio (1.0.1) from /usr/lib/python3.6/site-packages/sphinxcontrib_trio/__init__.py
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/sphinx/cmdline.py", line 304, in main
    app.build(args.force_all, filenames)
  File "/usr/lib/python3.6/site-packages/sphinx/application.py", line 331, in build
    self.builder.build_update()
  File "/usr/lib/python3.6/site-packages/sphinx/builders/__init__.py", line 342, in build_update
    'out of date' % len(to_build))
  File "/usr/lib/python3.6/site-packages/sphinx/builders/__init__.py", line 355, in build
    updated_docnames = set(self.env.update(self.config, self.srcdir, self.doctreedir))
  File "/usr/lib/python3.6/site-packages/sphinx/environment/__init__.py", line 565, in update
    self._read_serial(docnames, self.app)
  File "/usr/lib/python3.6/site-packages/sphinx/environment/__init__.py", line 584, in _read_serial
    self.read_doc(docname, app)
  File "/usr/lib/python3.6/site-packages/sphinx/environment/__init__.py", line 659, in read_doc
    doctree = read_doc(self.app, self, self.doc2path(docname))
  File "/usr/lib/python3.6/site-packages/sphinx/io.py", line 294, in read_doc
    pub.publish()
  File "/usr/lib/python3.6/site-packages/docutils/core.py", line 217, in publish
    self.settings)
  File "/usr/lib/python3.6/site-packages/docutils/readers/__init__.py", line 72, in read
    self.parse()
  File "/usr/lib/python3.6/site-packages/docutils/readers/__init__.py", line 78, in parse
    self.parser.parse(self.input, document)
  File "/usr/lib/python3.6/site-packages/sphinx/parsers.py", line 85, in parse
    self.statemachine.run(inputstring, document, inliner=self.inliner)
  File "/usr/lib/python3.6/site-packages/docutils/parsers/rst/states.py", line 171, in run
    input_source=document['source'])
  File "/usr/lib/python3.6/site-packages/docutils/statemachine.py", line 239, in run
    context, state, transitions)
  File "/usr/lib/python3.6/site-packages/docutils/statemachine.py", line 460, in check_line
    return method(match, context, next_state)
  File "/usr/lib/python3.6/site-packages/docutils/parsers/rst/states.py", line 2753, in underline
    self.section(title, source, style, lineno - 1, messages)
  File "/usr/lib/python3.6/site-packages/docutils/parsers/rst/states.py", line 327, in section
    self.new_subsection(title, lineno, messages)
  File "/usr/lib/python3.6/site-packages/docutils/parsers/rst/states.py", line 395, in new_subsection
    node=section_node, match_titles=True)
  File "/usr/lib/python3.6/site-packages/docutils/parsers/rst/states.py", line 282, in nested_parse
    node=node, match_titles=match_titles)
  File "/usr/lib/python3.6/site-packages/docutils/parsers/rst/states.py", line 196, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/usr/lib/python3.6/site-packages/docutils/statemachine.py", line 239, in run
    context, state, transitions)
  File "/usr/lib/python3.6/site-packages/docutils/statemachine.py", line 460, in check_line
    return method(match, context, next_state)
  File "/usr/lib/python3.6/site-packages/docutils/parsers/rst/states.py", line 2753, in underline
    self.section(title, source, style, lineno - 1, messages)
  File "/usr/lib/python3.6/site-packages/docutils/parsers/rst/states.py", line 327, in section
    self.new_subsection(title, lineno, messages)
  File "/usr/lib/python3.6/site-packages/docutils/parsers/rst/states.py", line 395, in new_subsection
    node=section_node, match_titles=True)
  File "/usr/lib/python3.6/site-packages/docutils/parsers/rst/states.py", line 282, in nested_parse
    node=node, match_titles=match_titles)
  File "/usr/lib/python3.6/site-packages/docutils/parsers/rst/states.py", line 196, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/usr/lib/python3.6/site-packages/docutils/statemachine.py", line 239, in run
    context, state, transitions)
  File "/usr/lib/python3.6/site-packages/docutils/statemachine.py", line 460, in check_line
    return method(match, context, next_state)
  File "/usr/lib/python3.6/site-packages/docutils/parsers/rst/states.py", line 2753, in underline
    self.section(title, source, style, lineno - 1, messages)
  File "/usr/lib/python3.6/site-packages/docutils/parsers/rst/states.py", line 327, in section
    self.new_subsection(title, lineno, messages)
  File "/usr/lib/python3.6/site-packages/docutils/parsers/rst/states.py", line 395, in new_subsection
    node=section_node, match_titles=True)
  File "/usr/lib/python3.6/site-packages/docutils/parsers/rst/states.py", line 282, in nested_parse
    node=node, match_titles=match_titles)
  File "/usr/lib/python3.6/site-packages/docutils/parsers/rst/states.py", line 196, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/usr/lib/python3.6/site-packages/docutils/statemachine.py", line 239, in run
    context, state, transitions)
  File "/usr/lib/python3.6/site-packages/docutils/statemachine.py", line 460, in check_line
    return method(match, context, next_state)
  File "/usr/lib/python3.6/site-packages/docutils/parsers/rst/states.py", line 2326, in explicit_markup
    nodelist, blank_finish = self.explicit_construct(match)
  File "/usr/lib/python3.6/site-packages/docutils/parsers/rst/states.py", line 2338, in explicit_construct
    return method(self, expmatch)
  File "/usr/lib/python3.6/site-packages/docutils/parsers/rst/states.py", line 2081, in directive
    directive_class, match, type_name, option_presets)
  File "/usr/lib/python3.6/site-packages/docutils/parsers/rst/states.py", line 2130, in run_directive
    result = directive_instance.run()
  File "/usr/lib/python3.6/site-packages/sphinx/ext/autodoc/directive.py", line 133, in run
    documenter.generate(more_content=self.content)
  File "/usr/lib/python3.6/site-packages/sphinx/ext/autodoc/__init__.py", line 747, in generate
    if not self.import_object():
  File "/usr/lib/python3.6/site-packages/sphinxcontrib_trio/__init__.py", line 350, in import_object
    obj = self.parent.__dict__.get(self.object_name)
AttributeError: 'NoneType' object has no attribute '__dict__'

From a quick skim, I think the issue is that somehow autodoc was trying to look up an unknown method (e.g. .. automethod:: SomeClass.misspelled_nmae), and we're crashing instead of reporting a proper error message.

Specifically, it looks like we need to port this fix: sphinx-doc/sphinx@1d742bd into sphinxcontrib-trio's version of MethodDocumentor.import_object

Well, I'm not entirely sure whether that's the actual issue because I'm not sure what exactly @thmo was doing or how to reproduce it, but this seems like a good idea regardless :-)

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

No branches or pull requests

1 participant