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

Fix #8084: autodoc: KeyError is raised on documenting a broken attribute #8085

Merged
merged 2 commits into from Aug 10, 2020

Conversation

tk0miya
Copy link
Member

@tk0miya tk0miya commented Aug 9, 2020

Feature or Bugfix

  • Bugfix

Purpose

…ken attribute

``typing.get_type_hints()`` raises KeyError when a class having invalid
__module__ was given.  This handles the exception not to crash on build
documents.
@efahl
Copy link

efahl commented Aug 9, 2020

I'm seeing a similar issue in sphinx/util/inspect.py at line 468, when processing a package that uses wxPython. It attempts to use 'sip' as the module key and get_type_hints raises a KeyError, crashing as described above. Is this part of the same issue, or should I file a new report?

@tk0miya
Copy link
Member Author

tk0miya commented Aug 9, 2020

@efahl Please file a new issue please. It seems latest Sphinx catches all kinds of exceptions at that location. So I feel strange that you got KeyError. I need to know about the error in detail (stacktrace, versions, extensions and so on).

@tk0miya tk0miya merged commit 38b868c into sphinx-doc:3.x Aug 10, 2020
@tk0miya tk0miya deleted the 8084_KeyError_for_broken_class branch August 10, 2020 05:46
@tk0miya
Copy link
Member Author

tk0miya commented Aug 10, 2020

Oops... I wrongly merged this into 3.x branch. I cherry-picked this to 3.2.x branch manually now.

tk0miya added a commit to tk0miya/sphinx that referenced this pull request Aug 10, 2020
… an attribute

Until Python 3.5.2, typing.get_type_hints() raises AttributeError if
given object does not have `__code__` attribute.  This handles the
exception not to crash building documents.

refs: python/cpython@991d14f
tk0miya added a commit to tk0miya/sphinx that referenced this pull request Aug 10, 2020
… an attribute

Until Python 3.5.2, typing.get_type_hints() raises AttributeError if
given object does not have `__code__` attribute.  This handles the
exception not to crash building documents.

Note: The AttributeError was fixed at 3.5.3
refs: python/cpython@991d14f
@efahl
Copy link

efahl commented Aug 10, 2020

@tk0miya Sorry, seems my report was a false alarm. It looks like #8085 fixes all cases, I must have misapplied it.

altendky added a commit to altendky/sphinx-autodoc-typehints that referenced this pull request Aug 16, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants