summaryrefslogtreecommitdiff
path: root/sphinx/util/inspect.py
diff options
context:
space:
mode:
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)