From 72ad81884360a9c792ed4fae32e68806e01067b5 Mon Sep 17 00:00:00 2001 From: Claudiu Popa Date: Mon, 11 Dec 2017 10:13:41 +0100 Subject: Don't emit catching-non-exception when a tuple component has unknown bases Close #1756 --- pylint/checkers/exceptions.py | 3 ++- pylint/test/functional/invalid_exceptions_caught.py | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/pylint/checkers/exceptions.py b/pylint/checkers/exceptions.py index 0d8c05954..2130a99be 100644 --- a/pylint/checkers/exceptions.py +++ b/pylint/checkers/exceptions.py @@ -305,7 +305,8 @@ class ExceptionsChecker(checkers.BaseChecker): if any(node is astroid.YES for node in inferred): # Don't emit if we don't know every component. return - if all(node and utils.inherit_from_std_ex(node) + if all(node and (utils.inherit_from_std_ex(node) or + not utils.has_known_bases(node)) for node in inferred): return diff --git a/pylint/test/functional/invalid_exceptions_caught.py b/pylint/test/functional/invalid_exceptions_caught.py index 2d87239e6..2b1dbacd8 100644 --- a/pylint/test/functional/invalid_exceptions_caught.py +++ b/pylint/test/functional/invalid_exceptions_caught.py @@ -121,3 +121,15 @@ try: raise Second except Second: pass + + +class SomeBase(UnknownError): + pass + + +EXCEPTIONS = (SomeBase, ValueError) + +try: + raise ValueError +except EXCEPTIONS: + pass -- cgit v1.2.1