Skip to content

Commit

Permalink
Fix a crash caused by not guarding against InferenceError when call…
Browse files Browse the repository at this point in the history
…ing `infer_call_result`

Close #3690
  • Loading branch information
PCManticore committed Jun 18, 2020
1 parent 9cdd479 commit 4e2529c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ What's New in Pylint 2.5.4?

Release date: TBA

* Fix a crash caused by not guarding against `InferenceError` when calling `infer_call_result`

Close #3690


What's New in Pylint 2.5.3?
===========================
Expand Down
11 changes: 7 additions & 4 deletions pylint/checkers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1134,10 +1134,13 @@ def _check_using_constant_test(self, node, test):
# If the constant node is a FunctionDef or Lambda then
#  it may be a illicit function call due to missing parentheses
call_inferred = None
if isinstance(inferred, astroid.FunctionDef):
call_inferred = inferred.infer_call_result()
elif isinstance(inferred, astroid.Lambda):
call_inferred = inferred.infer_call_result(node)
try:
if isinstance(inferred, astroid.FunctionDef):
call_inferred = inferred.infer_call_result()
elif isinstance(inferred, astroid.Lambda):
call_inferred = inferred.infer_call_result(node)
except astroid.InferenceError:
call_inferred = None
if call_inferred:
try:
for inf_call in call_inferred:
Expand Down
11 changes: 11 additions & 0 deletions tests/functional/r/regression_infer_call_result_3690.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# pylint: disable-msg=missing-docstring,too-few-public-methods,using-constant-test

class Class:
@property
@classmethod
def func(cls):
pass


if Class.func:
pass

0 comments on commit 4e2529c

Please sign in to comment.