summaryrefslogtreecommitdiff
path: root/astroid/protocols.py
diff options
context:
space:
mode:
Diffstat (limited to 'astroid/protocols.py')
-rw-r--r--astroid/protocols.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/astroid/protocols.py b/astroid/protocols.py
index 2cdf5548..57e5a231 100644
--- a/astroid/protocols.py
+++ b/astroid/protocols.py
@@ -14,6 +14,8 @@
# Copyright (c) 2018 Bryce Guinta <bryce.paul.guinta@gmail.com>
# Copyright (c) 2018 HoverHell <hoverhell@gmail.com>
# Copyright (c) 2019 Hugo van Kemenade <hugovk@users.noreply.github.com>
+# Copyright (c) 2020 Vilnis Termanis <vilnis.termanis@iotics.com>
+# Copyright (c) 2020 Ram Rachum <ram@rachum.com>
# Licensed under the LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html
# For details: https://github.com/PyCQA/astroid/blob/master/COPYING.LESSER
@@ -498,8 +500,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)
@@ -686,11 +688,10 @@ def starred_assigned_stmts(self, node=None, context=None, assign_path=None):
continue
# We're done unpacking.
- elts = list(elts)
packed = nodes.List(
ctx=Store, parent=self, lineno=lhs.lineno, col_offset=lhs.col_offset
)
- packed.postinit(elts=elts)
+ packed.postinit(elts=list(elts))
yield packed
break