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

AttributeError: '_ClientMethodFactory' object has no attribute '__code__' #6605

Closed
jeffrey856 opened this issue Jul 25, 2019 · 5 comments
Closed

Comments

@jeffrey856
Copy link

Issue:
Running make docs throw a AttributeError.

(v3nv) quokka@qcore:~/git/delet/dcp-cli$ make docs
make -C docs html
make[1]: Entering directory '/home/quokka/git/delet/dcp-cli/docs'
Running Sphinx v2.1.2
making output directory... done
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 3 source files that are out of date
updating environment: 3 added, 0 changed, 0 removed
reading sources... [ 33%] api                                                   
Exception occurred:
  File "/usr/lib/python3.6/inspect.py", line 186, in iscoroutinefunction
    object.__code__.co_flags & CO_COROUTINE)
AttributeError: '_ClientMethodFactory' object has no attribute '__code__'
The full traceback has been saved in /tmp/sphinx-err-6jwazei4.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
make[1]: *** [html] Error 2
make[1]: Leaving directory '/home/quokka/git/delet/dcp-cli/docs'
Makefile:47: recipe for target 'docs' failed
make: *** [docs] Error 2

Errors here:
https://github.com/HumanCellAtlas/dcp-cli/blob/34e6d610578c387726689861c7bb9bf62638e151/hca/util/__init__.py#L128

@tk0miya
Copy link
Member

tk0miya commented Jul 25, 2019

Thank you for reporting. Could you provide a full traceback file to us? It was saved into temporary directory on crashes. The error message let us know the location of the file like this:

The full traceback has been saved in /tmp/sphinx-err-6jwazei4.log, if you want to report the issue to the developers.

@tk0miya tk0miya modified the milestones: 2.1.3, 2.2.0 Jul 25, 2019
@jeffrey856
Copy link
Author

(v3nv) quokka@qcore:~/git/delet/dcp-cli$ cat /tmp/sphinx-err-t65m_a9h.log
# Sphinx version: 2.1.2
# Python version: 3.6.8 (CPython)
# Docutils version: 0.15.1 release
# Jinja2 version: 2.10.1
# Last messages:
#   building [mo]: targets for 0 po files that are out of date
#   
#   building [html]: targets for 3 source files that are out of date
#   
#   updating environment:
#   
#   3 added, 0 changed, 0 removed
#   
#   reading sources... [ 33%] api
#   
# Loaded extensions:
#   sphinx.ext.mathjax (2.1.2) from /home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/sphinx/ext/mathjax.py
#   sphinxcontrib.applehelp (1.0.1) from /home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/sphinxcontrib/applehelp/__init__.py
#   sphinxcontrib.devhelp (1.0.1) from /home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/sphinxcontrib/devhelp/__init__.py
#   sphinxcontrib.htmlhelp (1.0.2) from /home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/sphinxcontrib/htmlhelp/__init__.py
#   sphinxcontrib.serializinghtml (1.1.3) from /home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/sphinxcontrib/serializinghtml/__init__.py
#   sphinxcontrib.qthelp (1.0.2) from /home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/sphinxcontrib/qthelp/__init__.py
#   alabaster (0.7.12) from /home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/alabaster/__init__.py
#   sphinx.ext.autodoc (2.1.2) from /home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/sphinx/ext/autodoc/__init__.py
#   sphinx.ext.viewcode (2.1.2) from /home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/sphinx/ext/viewcode.py
#   sphinxarg.ext (unknown version) from /home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/sphinxarg/ext.py
Traceback (most recent call last):
  File "/home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/sphinx/cmd/build.py", line 284, in build_main
    app.build(args.force_all, filenames)
  File "/home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/sphinx/application.py", line 345, in build
    self.builder.build_update()
  File "/home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/sphinx/builders/__init__.py", line 319, in build_update
    len(to_build))
  File "/home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/sphinx/builders/__init__.py", line 332, in build
    updated_docnames = set(self.read())
  File "/home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/sphinx/builders/__init__.py", line 438, in read
    self._read_serial(docnames)
  File "/home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/sphinx/builders/__init__.py", line 460, in _read_serial
    self.read_doc(docname)
  File "/home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/sphinx/builders/__init__.py", line 504, in read_doc
    doctree = read_doc(self.app, self.env, self.env.doc2path(docname))
  File "/home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/sphinx/io.py", line 325, in read_doc
    pub.publish()
  File "/home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/docutils/core.py", line 217, in publish
    self.settings)
  File "/home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/sphinx/io.py", line 113, in read
    self.parse()
  File "/home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/docutils/readers/__init__.py", line 77, in parse
    self.parser.parse(self.input, document)
  File "/home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/sphinx/parsers.py", line 94, in parse
    self.statemachine.run(inputlines, document, inliner=self.inliner)
  File "/home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/docutils/parsers/rst/states.py", line 171, in run
    input_source=document['source'])
  File "/home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/docutils/statemachine.py", line 239, in run
    context, state, transitions)
  File "/home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/docutils/statemachine.py", line 460, in check_line
    return method(match, context, next_state)
  File "/home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/docutils/parsers/rst/states.py", line 3007, in text
    self.section(title.lstrip(), source, style, lineno + 1, messages)
  File "/home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/docutils/parsers/rst/states.py", line 327, in section
    self.new_subsection(title, lineno, messages)
  File "/home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/docutils/parsers/rst/states.py", line 395, in new_subsection
    node=section_node, match_titles=True)
  File "/home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/docutils/parsers/rst/states.py", line 282, in nested_parse
    node=node, match_titles=match_titles)
  File "/home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/docutils/parsers/rst/states.py", line 196, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/docutils/statemachine.py", line 239, in run
    context, state, transitions)
  File "/home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/docutils/statemachine.py", line 460, in check_line
    return method(match, context, next_state)
  File "/home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/docutils/parsers/rst/states.py", line 2344, in explicit_markup
    nodelist, blank_finish = self.explicit_construct(match)
  File "/home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/docutils/parsers/rst/states.py", line 2356, in explicit_construct
    return method(self, expmatch)
  File "/home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/docutils/parsers/rst/states.py", line 2099, in directive
    directive_class, match, type_name, option_presets)
  File "/home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/docutils/parsers/rst/states.py", line 2148, in run_directive
    result = directive_instance.run()
  File "/home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/sphinx/ext/autodoc/directive.py", line 150, in run
    documenter.generate(more_content=self.content)
  File "/home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/sphinx/ext/autodoc/__init__.py", line 760, in generate
    self.document_members(all_members)
  File "/home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/sphinx/ext/autodoc/__init__.py", line 681, in document_members
    check_module=members_check_module and not isattr)
  File "/home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/sphinx/ext/autodoc/__init__.py", line 1234, in generate
    all_members=all_members)
  File "/home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/sphinx/ext/autodoc/__init__.py", line 760, in generate
    self.document_members(all_members)
  File "/home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/sphinx/ext/autodoc/__init__.py", line 1222, in document_members
    super().document_members(all_members)
  File "/home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/sphinx/ext/autodoc/__init__.py", line 681, in document_members
    check_module=members_check_module and not isattr)
  File "/home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/sphinx/ext/autodoc/__init__.py", line 750, in generate
    self.add_directive_header(sig)
  File "/home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/sphinx/ext/autodoc/__init__.py", line 1352, in add_directive_header
    if inspect.iscoroutinefunction(obj):
  File "/home/quokka/git/delet/dcp-cli/v3nv/lib/python3.6/site-packages/sphinx/util/inspect.py", line 224, in iscoroutinefunction
    if inspect.iscoroutinefunction(obj):
  File "/usr/lib/python3.6/inspect.py", line 186, in iscoroutinefunction
    object.__code__.co_flags & CO_COROUTINE)
AttributeError: '_ClientMethodFactory' object has no attribute '__code__'

@noelwilsondel
Copy link

I'm also getting the same error.

@tk0miya
Copy link
Member

tk0miya commented Aug 18, 2019

Reproduced with following code:

import inspect
import types

class Methodlike():
    def __call__(self):
        pass

method = types.MethodType(Methodlike(), object())
inspect.iscoroutinefunction(method)

It seems iscoroutinefunction() crashes with custom method like objects.

tk0miya added a commit to tk0miya/sphinx that referenced this issue Aug 18, 2019
tk0miya added a commit that referenced this issue Aug 18, 2019
Fix #6605: autodoc: crashed when target code contains custom method-like objects
@tk0miya
Copy link
Member

tk0miya commented Aug 18, 2019

Fixed by #6657.
Thank you for reporting.

@tk0miya tk0miya closed this as completed Aug 18, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 2, 2021
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

3 participants