diff options
author | Sylvain Thénault <sylvain.thenault@logilab.fr> | 2013-03-28 08:13:08 +0100 |
---|---|---|
committer | Sylvain Thénault <sylvain.thenault@logilab.fr> | 2013-03-28 08:13:08 +0100 |
commit | 67af81a655bebebd387f0c13ba38f45aab82ad44 (patch) | |
tree | 20109bf457fb1b06609ddc0a22583380ad574dbc /node_classes.py | |
parent | d4cc195b05243be776eb40464a61d4fc376728ff (diff) | |
download | astroid-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.py | 15 |
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 |