diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index eee4da9a43..8807395585 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -595,3 +595,6 @@ contributors: * Eero Vuojolahti: contributor * Kian-Meng, Ang: contributor + +* Julia Eskew (doctoryes): contributor + - Fixed issue 5646, handle when the 'ancestors' attribute is not present in an object diff --git a/ChangeLog b/ChangeLog index 2bf37a089a..c9d86d070c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -191,6 +191,15 @@ Release date: TBA (Ie. not necessarily at the end) +What's New in Pylint 2.12.3? +============================ +Release date: + +* Fixed handling of missing 'ancestors' object attribute. + + Closes #5646 + + What's New in Pylint 2.12.2? ============================ Release date: 2021-11-25 diff --git a/doc/whatsnew/2.12.rst b/doc/whatsnew/2.12.rst index c47f2e91a9..586fc50d31 100644 --- a/doc/whatsnew/2.12.rst +++ b/doc/whatsnew/2.12.rst @@ -255,3 +255,7 @@ Other Changes or ``not in`` checks Closes #5323 + +* Fixed handling of missing 'ancestors' object attribute. + + Closes #5646 diff --git a/pylint/checkers/refactoring/implicit_booleaness_checker.py b/pylint/checkers/refactoring/implicit_booleaness_checker.py index 6167e3e88f..3a06375c99 100644 --- a/pylint/checkers/refactoring/implicit_booleaness_checker.py +++ b/pylint/checkers/refactoring/implicit_booleaness_checker.py @@ -213,5 +213,5 @@ def base_classes_of_node(instance: nodes.ClassDef) -> List[str]: """Return all the classes names that a ClassDef inherit from including 'object'.""" try: return [instance.name] + [x.name for x in instance.ancestors()] - except TypeError: + except (TypeError, AttributeError): return [instance.name]