diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2015-10-26 12:30:08 +0000 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2015-10-26 12:30:08 +0000 |
commit | 8a0343728bc9b578d533ef5aa21e1412a8951ce6 (patch) | |
tree | 0bfe86d443ed10dc9a5b41d83d8e1ab6b240dd69 /astroid/scoped_nodes.py | |
parent | 033a215bb1d1a7f4b954ef99667e41d9e6fed92b (diff) | |
download | astroid-8a0343728bc9b578d533ef5aa21e1412a8951ce6.tar.gz |
Class.getattr('__mro__') returns the actual MRO.
Also, Class.getattr('__bases__') returns actual bases.
It previously didn't work correctly, because it was putting the
entire ancestors into the Tuple object and it put those classes
into the wrong attribute.
Closes issue #128.
Diffstat (limited to 'astroid/scoped_nodes.py')
-rw-r--r-- | astroid/scoped_nodes.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/astroid/scoped_nodes.py b/astroid/scoped_nodes.py index 31fc2f8..e6e3324 100644 --- a/astroid/scoped_nodes.py +++ b/astroid/scoped_nodes.py @@ -1359,14 +1359,16 @@ class ClassDef(mixins.FilterStmtsMixin, LocalsDictNodeNG, if name in self.special_attributes: if name == '__module__': return [node_classes.const_factory(self.root().qname())] + values - # FIXME: do we really need the actual list of ancestors? - # returning [Tuple()] + values don't break any test - # this is ticket http://www.logilab.org/ticket/52785 - # XXX need proper meta class handling + MRO implementation - if name == '__bases__' or (name == '__mro__' and self.newstyle): + if name == '__bases__': node = node_classes.Tuple() - node.items = self.ancestors(recurs=True, context=context) + elts = list(self._inferred_bases(context)) + node.postinit(elts=elts) return [node] + values + if name == '__mro__' and self.newstyle: + mro = self.mro() + node = node_classes.Tuple() + node.postinit(elts=mro) + return [node] return std_special_attributes(self, name) # don't modify the list in self.locals! values = list(values) |