summaryrefslogtreecommitdiff
path: root/node_classes.py
diff options
context:
space:
mode:
authorSylvain Thénault <sylvain.thenault@logilab.fr>2013-03-28 08:13:08 +0100
committerSylvain Thénault <sylvain.thenault@logilab.fr>2013-03-28 08:13:08 +0100
commit67af81a655bebebd387f0c13ba38f45aab82ad44 (patch)
tree20109bf457fb1b06609ddc0a22583380ad574dbc /node_classes.py
parentd4cc195b05243be776eb40464a61d4fc376728ff (diff)
downloadastroid-git-67af81a655bebebd387f0c13ba38f45aab82ad44.tar.gz
don't call const_factory for builtin types subclasses, this will trigger error later. Closes #124337
--HG-- branch : stable
Diffstat (limited to 'node_classes.py')
-rw-r--r--node_classes.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/node_classes.py b/node_classes.py
index e3f1c8db..b6ab6099 100644
--- a/node_classes.py
+++ b/node_classes.py
@@ -893,18 +893,19 @@ _update_const_classes()
def const_factory(value):
"""return an astng node for a python value"""
- # since const_factory is called to evaluate content of container (eg list,
- # tuple), it may be called with some node as argument that should be left
- # untouched
+ # 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
try:
return CONST_CLS[value.__class__](value)
except (KeyError, AttributeError):
- # some constants (like from gtk._gtk) don't have their class in
- # CONST_CLS, though we can "assert isinstance(value, tuple(CONST_CLS))"
- if isinstance(value, tuple(CONST_CLS)):
- return Const(value)
node = EmptyNode()
node.object = value
return node