-
-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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`)
- Loading branch information
Showing
2 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters