diff --git a/ChangeLog b/ChangeLog index e5fd0d9083..f83dd87286 100644 --- a/ChangeLog +++ b/ChangeLog @@ -23,6 +23,10 @@ Release Date: TBA Close PyCQA/pylint#3549 +* Protect against ``infer_call_result`` failing with `InferenceError` in `Super.getattr()` + + Close PyCQA/pylint#3529 + What's New in astroid 2.4.0? ============================ diff --git a/astroid/objects.py b/astroid/objects.py index 68d74aa2f3..fb782e6d7b 100644 --- a/astroid/objects.py +++ b/astroid/objects.py @@ -187,7 +187,12 @@ def igetattr(self, name, context=None): yield inferred elif isinstance(inferred, Property): function = inferred.function - yield from function.infer_call_result(caller=self, context=context) + try: + yield from function.infer_call_result( + caller=self, context=context + ) + except exceptions.InferenceError: + yield util.Uninferable elif bases._is_property(inferred): # TODO: support other descriptors as well. try: diff --git a/tests/unittest_inference.py b/tests/unittest_inference.py index e267f97022..cfbcd6f86b 100644 --- a/tests/unittest_inference.py +++ b/tests/unittest_inference.py @@ -5818,5 +5818,33 @@ def __new__(cls, name, bases, dictionary): assert dunder_new.implicit_parameters() == 0 +def test_super_inference_of_abstract_property(): + code = """ + from abc import abstractmethod + + class A: + @property + def test(self): + return "super" + + class C: + @property + @abstractmethod + def test(self): + "abstract method" + + class B(A, C): + + @property + def test(self): + super() #@ + + """ + node = extract_node(code) + inferred = next(node.infer()) + test = inferred.getattr("test") + assert len(test) == 2 + + if __name__ == "__main__": unittest.main()