inspect: return obj.__dict__[name] if there is an exception

When using a cached property, Sphinx tries to access the actual property
of an object which raises NotImplementedError. In these cases, we fall
back to inspecting the __dict__ and returning that instead.
This commit is contained in:
Sean Farley 2016-06-11 13:52:12 -07:00
parent 518dad93e3
commit 6f058ba173

View File

@ -108,6 +108,10 @@ def safe_getattr(obj, name, *defargs):
try:
return getattr(obj, name, *defargs)
except Exception:
# sometimes accessing a property raises an exception (e.g.
# NotImplementedError), so let's try to read the attribute directly
if name in obj.__dict__:
return obj.__dict__[name]
# this is a catch-all for all the weird things that some modules do
# with attribute access
if defargs: