Fix #8655: autodoc: Crashes when object raises an exception 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.
This commit is contained in:
Takeshi KOMIYA
2021-01-05 23:00:23 +09:00
parent 4755557a7d
commit a51c8a5652
2 changed files with 7 additions and 1 deletions

View File

@@ -16,6 +16,9 @@ Features added
Bugs fixed
----------
* #8655: autodoc: Failed to generate document if target module contains an
object that raises an exception on ``hasattr()``
Testing
--------