diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2019-02-19 09:13:07 +0100 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2019-02-19 09:21:45 +0100 |
commit | 1ae9fcc6b1f83bad403da4f6cc3e69ddb94d49d4 (patch) | |
tree | 0f4a9a51163cb99c292a7a149dedac48acfc09b5 /pylint/test/functional | |
parent | 5b2354306e7e608ca02479edd99e5255d13bd0fa (diff) | |
download | pylint-git-1ae9fcc6b1f83bad403da4f6cc3e69ddb94d49d4.tar.gz |
Protect against `NonDeducibleTypeHierarchy` when calling semi-private `is_subtype`
`astroid.helpers.is_subtype` raises `NonDeducibleTypeHierarchy` when it cannot infer
the base classes of the given types, but that makes sense in its context given that
the method is mostly used to inform the inference process about the hierarchy of classes.
Doesn't make that much sense for ``pylint`` itself, which is why we're handling the
exception here, rather than in ``astroid``
Close PyCQA/astroid#644
Diffstat (limited to 'pylint/test/functional')
-rw-r--r-- | pylint/test/functional/try_except_raise_crash.py | 25 | ||||
-rw-r--r-- | pylint/test/functional/try_except_raise_crash.txt | 1 |
2 files changed, 26 insertions, 0 deletions
diff --git a/pylint/test/functional/try_except_raise_crash.py b/pylint/test/functional/try_except_raise_crash.py new file mode 100644 index 000000000..7a1f8d972 --- /dev/null +++ b/pylint/test/functional/try_except_raise_crash.py @@ -0,0 +1,25 @@ +# pylint: disable=missing-docstring,too-many-ancestors, broad-except +import collections.abc +from typing import TYPE_CHECKING, Any, MutableMapping + +if TYPE_CHECKING: + BaseClass = MutableMapping[str, Any] +else: + BaseClass = collections.abc.MutableMapping + + +class TestBaseException(BaseClass): + pass + + +class TestException(TestBaseException): + pass + + +def test(): + try: + 1 / 0 + except TestException: # [try-except-raise] + raise + except Exception: + pass diff --git a/pylint/test/functional/try_except_raise_crash.txt b/pylint/test/functional/try_except_raise_crash.txt new file mode 100644 index 000000000..a99476ab9 --- /dev/null +++ b/pylint/test/functional/try_except_raise_crash.txt @@ -0,0 +1 @@ +try-except-raise:22:test:The except handler raises immediately |