summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorZen Lee <53538590+zenlyj@users.noreply.github.com>2023-05-15 20:35:33 +0800
committerGitHub <noreply@github.com>2023-05-15 08:35:33 -0400
commit2c9d58563aa8268cdcb2ffa3e72d0776b3cf01ee (patch)
tree25bccdd9b0b63ef98ac7c259a057a406e35c9aed /tests
parent4e48d46b7239c2d7a70a05929fd49595d45cc29f (diff)
downloadpylint-git-2c9d58563aa8268cdcb2ffa3e72d0776b3cf01ee.tar.gz
Regression fix for `unused-variable` false negative (#8684)
Diffstat (limited to 'tests')
-rw-r--r--tests/functional/u/unused/unused_variable.py17
-rw-r--r--tests/functional/u/unused/unused_variable.txt1
2 files changed, 18 insertions, 0 deletions
diff --git a/tests/functional/u/unused/unused_variable.py b/tests/functional/u/unused/unused_variable.py
index 9dabe5b59..f15ae7557 100644
--- a/tests/functional/u/unused/unused_variable.py
+++ b/tests/functional/u/unused/unused_variable.py
@@ -199,3 +199,20 @@ def func6():
nonlocal_writer()
assert a == 9, a
+
+def test_regression_8595():
+ # pylint: disable=broad-exception-caught
+ import logging
+ def compute():
+ pass
+ try:
+ compute()
+ error = False
+ except Exception as e:
+ logging.error(e)
+ error = True
+ if error:
+ try:
+ compute()
+ except Exception as e: # [unused-variable]
+ pass
diff --git a/tests/functional/u/unused/unused_variable.txt b/tests/functional/u/unused/unused_variable.txt
index 19983d536..609ce9fef 100644
--- a/tests/functional/u/unused/unused_variable.txt
+++ b/tests/functional/u/unused/unused_variable.txt
@@ -26,3 +26,4 @@ unused-variable:150:4:154:26:func4:Unused variable 'error':UNDEFINED
redefined-outer-name:153:8:154:26:func4:Redefining name 'error' from outer scope (line 150):UNDEFINED
unused-variable:161:4:162:12:main:Unused variable 'e':UNDEFINED
undefined-loop-variable:168:10:168:11:main:Using possibly undefined loop variable 'e':UNDEFINED
+unused-variable:217:8:218:16:test_regression_8595:Unused variable 'e':UNDEFINED