Skip to content

Fix #8655: autodoc: Crashes when object raises an exception on hasattr()#8656

Merged
tk0miya merged 1 commit intosphinx-doc:3.4.xfrom
tk0miya:8655_exception_on_hasattr
Jan 6, 2021
Merged

Fix #8655: autodoc: Crashes when object raises an exception on hasattr()#8656
tk0miya merged 1 commit intosphinx-doc:3.4.xfrom
tk0miya:8655_exception_on_hasattr

Conversation

@tk0miya
Copy link
Copy Markdown
Member

@tk0miya tk0miya commented Jan 5, 2021

Feature or Bugfix

  • Bugfix

Purpose

… on hasattr()

autodoc crashes when the target object raises an exception on
`hasattr()`.  The `hasattr()` function internally calls the
`obj.__getattr__()` or `obj.__getattribute__()` of the target object.
Hence the reaction can be changed on the target object.

This starts to use `safe_getattr()` to check the object is mocked or not
and to prevent an unexpected error.
@tk0miya tk0miya added this to the 3.4.3 milestone Jan 5, 2021
@tk0miya tk0miya merged commit ac12d8d into sphinx-doc:3.4.x Jan 6, 2021
@tk0miya tk0miya deleted the 8655_exception_on_hasattr branch January 6, 2021 17:12
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 18, 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.

1 participant