From 53a20335357bbd734d74c3bfe22e3518f74f4d11 Mon Sep 17 00:00:00 2001 From: Andrew Haigh Date: Mon, 24 May 2021 19:21:30 +1000 Subject: Fix inference cycle in getattr when a base is an astroid.Attribute (#934) * Fix inference cycle in getattr when a base is an astroid.Attribute Ref #904. `getattr` attempts to find values on `self.ancestors`, which infers each node listed in `self.bases`. Removing or resetting the context passed to ancestors allows it to infer the nodes, but opens up the possibility of cycles through recursive definitions. We should be able to infer the value of the base node correctly as a `ClassDef`. The root of this issue stems from the fact that `infer_attribute` attempts to temporarily set `context.boundnode`, but when unwrapping its changes it sets the `boundnode` to `None` instead of its previous value, which loses state and causes the inference of the `Attribute` node to have a duplicate key: once when looking up the class definition (which should have `boundnode = None`), and once when inferring the (other) attribute value (which should not have `boundnode = None`) * Update changelog --- ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'ChangeLog') diff --git a/ChangeLog b/ChangeLog index 6097526b..c606b761 100644 --- a/ChangeLog +++ b/ChangeLog @@ -41,6 +41,10 @@ Release Date: TBA Closes #922 +* Fix inference of attributes defined in a base class that is an inner class + + Closes #904 + What's New in astroid 2.5.6? ============================ -- cgit v1.2.1