summaryrefslogtreecommitdiff
path: root/astroid/protocols.py
diff options
context:
space:
mode:
Diffstat (limited to 'astroid/protocols.py')
-rw-r--r--astroid/protocols.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/astroid/protocols.py b/astroid/protocols.py
index 2cdf5548..dc66ca2c 100644
--- a/astroid/protocols.py
+++ b/astroid/protocols.py
@@ -498,8 +498,8 @@ def _infer_context_manager(self, mgr, context):
elif isinstance(inferred, bases.Instance):
try:
enter = next(inferred.igetattr("__enter__", context=context))
- except (exceptions.InferenceError, exceptions.AttributeInferenceError):
- raise exceptions.InferenceError(node=inferred)
+ except (exceptions.InferenceError, exceptions.AttributeInferenceError) as exc:
+ raise exceptions.InferenceError(node=inferred) from exc
if not isinstance(enter, bases.BoundMethod):
raise exceptions.InferenceError(node=enter)
yield from enter.infer_call_result(self, context)