summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2020-06-18 08:43:52 +0200
committerClaudiu Popa <pcmanticore@gmail.com>2020-06-18 09:01:16 +0200
commit36250aa1370a1b0e496185eafed3afa145589d1a (patch)
treecde9cafff7575eb9494f19b16331c348d61fde5f
parent5016fd1adeece312bbe19ff41416149c6a57d464 (diff)
downloadpylint-git-36250aa1370a1b0e496185eafed3afa145589d1a.tar.gz
Fix a crash caused by not guarding against `InferenceError` when calling `infer_call_result`
Close #3690
-rw-r--r--ChangeLog9
-rw-r--r--pylint/checkers/base.py11
-rw-r--r--tests/functional/r/regression_infer_call_result_3690.py11
3 files changed, 27 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 33128066d..cc7d08901 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -34,6 +34,15 @@ Release date: TBA
* Fix `pre-commit` config that could lead to undetected duplicate lines of code
+
+What's New in Pylint 2.5.4?
+===========================
+
+* Fix a crash caused by not guarding against `InferenceError` when calling `infer_call_result`
+
+ Close #3690
+
+
What's New in Pylint 2.5.3?
===========================
diff --git a/pylint/checkers/base.py b/pylint/checkers/base.py
index 890cec5bc..e93ad66e5 100644
--- a/pylint/checkers/base.py
+++ b/pylint/checkers/base.py
@@ -1134,10 +1134,13 @@ class BasicChecker(_BasicChecker):
# 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:
diff --git a/tests/functional/r/regression_infer_call_result_3690.py b/tests/functional/r/regression_infer_call_result_3690.py
new file mode 100644
index 000000000..0949d9439
--- /dev/null
+++ b/tests/functional/r/regression_infer_call_result_3690.py
@@ -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