summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Thénault <sylvain.thenault@logilab.fr>2013-03-28 08:53:41 +0100
committerSylvain Thénault <sylvain.thenault@logilab.fr>2013-03-28 08:53:41 +0100
commit22e37ca5352d256103c0887908890c76826bc5f1 (patch)
treeadb842627234bdbf93ed63ff984066182ed00c0f
parent94ee18738092cd150a0ca41d86121638d0390cac (diff)
downloadastroid-git-22e37ca5352d256103c0887908890c76826bc5f1.tar.gz
[cleanup] don't call const_factory with astng nodes
--HG-- branch : stable
-rw-r--r--node_classes.py14
-rw-r--r--scoped_nodes.py13
2 files changed, 11 insertions, 16 deletions
diff --git a/node_classes.py b/node_classes.py
index b6ab6099..a4282b62 100644
--- a/node_classes.py
+++ b/node_classes.py
@@ -894,15 +894,11 @@ _update_const_classes()
def const_factory(value):
"""return an astng node for a python value"""
# XXX we should probably be stricter here and only consider stuff in
- # CONST_CLS or do better treatment:
- #
- # * shall we really support nodes as argument? if so, detail cases where
- # * this may occurs
- #
- # * in case where value is not in CONST_CLS, we should rather recall the
- # builder on this value than returning an empty node
- if isinstance(value, NodeNG):
- return value
+ # CONST_CLS or do better treatment: in case where value is not in CONST_CLS,
+ # we should rather recall the builder on this value than returning an empty
+ # node (another option being that const_factory shouldn't be called with something
+ # not in CONST_CLS)
+ assert not isinstance(value, NodeNG)
try:
return CONST_CLS[value.__class__](value)
except (KeyError, AttributeError):
diff --git a/scoped_nodes.py b/scoped_nodes.py
index 46815ac3..dc4ca14d 100644
--- a/scoped_nodes.py
+++ b/scoped_nodes.py
@@ -872,15 +872,14 @@ class Class(Statement, LocalsDictNodeNG, FilterStmtsMixin):
if name in self.special_attributes:
if name == '__module__':
return [cf(self.root().qname())] + values
- # FIXME : what is expected by passing the list of ancestors to cf:
- # you can just do [cf(tuple())] + values without breaking any test
+ # 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
- if name == '__bases__':
- return [cf(tuple(self.ancestors(recurs=False, context=context)))] + values
# XXX need proper meta class handling + MRO implementation
- if name == '__mro__' and self.newstyle:
- # XXX mro is read-only but that's not our job to detect that
- return [cf(tuple(self.ancestors(recurs=True, context=context)))] + values
+ if name == '__bases__' or (name == '__mro__' and self.newstyle):
+ node = Tuple()
+ node.items = self.ancestors(recurs=True, context=context)
+ return [node] + values
return std_special_attributes(self, name)
# don't modify the list in self.locals!
values = list(values)