From 92f556842c84a2b3cc33a1638fc625b4f67d0d1f Mon Sep 17 00:00:00 2001 From: Ram Rachum Date: Fri, 12 Jun 2020 13:00:58 +0300 Subject: Fix exception causes in helpers.py --- astroid/helpers.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'astroid/helpers.py') diff --git a/astroid/helpers.py b/astroid/helpers.py index 1c84651d..8ab68799 100644 --- a/astroid/helpers.py +++ b/astroid/helpers.py @@ -190,9 +190,9 @@ def _type_check(type1, type2): return False try: return type1 in type2.mro()[:-1] - except exceptions.MroError: + except exceptions.MroError as e: # The MRO is invalid. - raise exceptions._NonDeducibleTypeHierarchy + raise exceptions._NonDeducibleTypeHierarchy from e def is_subtype(type1, type2): @@ -261,10 +261,10 @@ def object_len(node, context=None): try: len_call = next(node_type.igetattr("__len__", context=context)) - except exceptions.AttributeInferenceError: + except exceptions.AttributeInferenceError as e: raise exceptions.AstroidTypeError( "object of type '{}' has no len()".format(node_type.pytype()) - ) + ) from e result_of_len = next(len_call.infer_call_result(node, context)) if ( -- cgit v1.2.1