summaryrefslogtreecommitdiff
path: root/sphinx/util/inspect.py
diff options
context:
space:
mode:
authorRam Rachum <ram@rachum.com>2020-06-14 00:46:19 +0300
committerRam Rachum <ram@rachum.com>2020-06-14 14:37:16 +0300
commit53c1dff91c0b7100e1ce1b51acbf0fffbc10cf9c (patch)
tree93bca0f98dfcf0f83f32987f898a7fbafe8f25dd /sphinx/util/inspect.py
parent0fc97a0b56d31f2703ff42dfe946e8d11d667909 (diff)
downloadsphinx-git-53c1dff91c0b7100e1ce1b51acbf0fffbc10cf9c.tar.gz
Fix exception causes all over the codebase
Diffstat (limited to 'sphinx/util/inspect.py')
-rw-r--r--sphinx/util/inspect.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/sphinx/util/inspect.py b/sphinx/util/inspect.py
index d4928c847..3077f9eb2 100644
--- a/sphinx/util/inspect.py
+++ b/sphinx/util/inspect.py
@@ -321,7 +321,7 @@ def safe_getattr(obj: Any, name: str, *defargs: Any) -> Any:
"""A getattr() that turns all exceptions into AttributeErrors."""
try:
return getattr(obj, name, *defargs)
- except Exception:
+ except Exception as exc:
# sometimes accessing a property raises an exception (e.g.
# NotImplementedError), so let's try to read the attribute directly
try:
@@ -336,7 +336,7 @@ def safe_getattr(obj: Any, name: str, *defargs: Any) -> Any:
if defargs:
return defargs[0]
- raise AttributeError(name)
+ raise AttributeError(name) from exc
def safe_getmembers(object: Any, predicate: Callable[[str], bool] = None,
@@ -385,8 +385,8 @@ def object_description(object: Any) -> str:
for x in sorted_values)
try:
s = repr(object)
- except Exception:
- raise ValueError
+ except Exception as exc:
+ raise ValueError from exc
# Strip non-deterministic memory addresses such as
# ``<__main__.A at 0x7f68cb685710>``
s = memory_address_re.sub('', s)