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

Sphinx inspects objects, can lead to needless build errors #7516

Closed
a-recknagel opened this issue Apr 19, 2020 · 1 comment
Closed

Sphinx inspects objects, can lead to needless build errors #7516

a-recknagel opened this issue Apr 19, 2020 · 1 comment

Comments

@a-recknagel
Copy link
Contributor

a-recknagel commented Apr 19, 2020

Describe the bug
If I have an object in one of my modules that raises some kind of error in its __getattr__, it will prevent sphinx (with autodocs) from building docs for said module.

To Reproduce
Put something like this in a file and try to generate docs for it.

class Foo:
    def __getattr__(self, item):
        raise RuntimeError('fufufu!')

foo = Foo()

See also https://github.com/a-recknagel/Flask-Shortcut/pull/7/checks?check_run_id=600063576 for an actual error, the workflow and the run logs should give instructions on how reproduce it in detail.

Environment info

  • OS: on both windows and ubuntu
  • Python version: 3.6.x
  • Sphinx version: 3.0.2 (3.0.1 is still fine)
  • Sphinx extensions: sphinx.ext.autodoc

Additional context
This bug was introduced with 3.0.2 in this commit: e9b6437#diff-48ca4d6544b092f35d729127500bff5fR581. I think it should be ok to just surround it with a bare try..except, since there is no info whatsoever which kind of errors a user might raise. In my case, it was flask's request proxy, which probably a few more people will run into. So here is part of the stacktrace to help them google the issue:

$ sphinx-build docs/ public/ -b html
Running Sphinx v3.0.2
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 2 source files that are out of date
updating environment: [new config] 2 added, 0 changed, 0 removed
reading sources... [ 50%] autodoc/flask_shortcut
Exception occurred:
 File "...\venv\lib\site-packages\flask\globals.py", line 38, in _lookup_req_object
   raise RuntimeError(_request_ctx_err_msg)
RuntimeError: Working outside of request context.

This typically means that you attempted to use functionality that needed
an active HTTP request.  Consult the documentation on testing for
information about how to avoid this problem.
The full traceback has been saved in ...\AppData\Local\Temp\sphinx-err-rzyl88fm.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!
@tk0miya tk0miya added this to the 3.0.3 milestone Apr 20, 2020
tk0miya added a commit that referenced this issue Apr 20, 2020
@tk0miya tk0miya closed this as completed Apr 20, 2020
a-recknagel added a commit to a-recknagel/Flask-Shortcut that referenced this issue Apr 22, 2020
* Adding function mappings

- as it says on the tin, we can now add functions as route 'condition -> response' shortcuts
- I learned that "routing function" are actually called views, so I did some renaming
- fixed some documentation examples that were malformed
- nailing sphinx to 3.0.1 because of sphinx-doc/sphinx#7516
@jace
Copy link

jace commented Jan 7, 2021

I'm encountering this with Sphinx 3.4.2 a few lines above, in the hasattr call. The problem appears to have been introduced in 4761692 10 days ago.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 15, 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