diff options
author | Emile Anclin <emile.anclin@logilab.fr> | 2010-10-11 16:31:41 +0200 |
---|---|---|
committer | Emile Anclin <emile.anclin@logilab.fr> | 2010-10-11 16:31:41 +0200 |
commit | 361e248001cdc69f2c3328cc1071646ca8f61f27 (patch) | |
tree | c7813eaf07a6fd4e6231008115874f01f07aa333 | |
parent | f529b2e487e546d2266f7477a6ca998f11773014 (diff) | |
download | astroid-git-361e248001cdc69f2c3328cc1071646ca8f61f27.tar.gz |
Bytes: are just constants like Str and Num
-rw-r--r-- | _nodes_ast.py | 10 | ||||
-rw-r--r-- | inference.py | 3 |
2 files changed, 11 insertions, 2 deletions
diff --git a/_nodes_ast.py b/_nodes_ast.py index a49a2fd1..b1facea3 100644 --- a/_nodes_ast.py +++ b/_nodes_ast.py @@ -529,14 +529,20 @@ class TreeRebuilder(RebuildVisitor): newnode.set_line_info(newnode.last_child()) return newnode + def visit_bytes(self, node, parent): + """visit a Bytes node by returning a fresh instance of Const""" + newnode = new.Const(node.s) + self._set_infos(node, newnode, parent) + return newnode + def visit_num(self, node, parent): - """visit a a Num node by returning a fresh instance of Const""" + """visit a Num node by returning a fresh instance of Const""" newnode = new.Const(node.n) self._set_infos(node, newnode, parent) return newnode def visit_str(self, node, parent): - """visit a a Str node by returning a fresh instance of Const""" + """visit a Str node by returning a fresh instance of Const""" newnode = new.Const(node.s) self._set_infos(node, newnode, parent) return newnode diff --git a/inference.py b/inference.py index 257177c0..25c5fed5 100644 --- a/inference.py +++ b/inference.py @@ -25,6 +25,7 @@ from __future__ import generators __doctype__ = "restructuredtext en" from itertools import chain +import sys try: GeneratorExit # introduced in py2.5 @@ -52,6 +53,8 @@ _CONST_PROXY = { unicode: MANAGER.astng_from_class(unicode), } _CONST_PROXY[type(None)].parent = _CONST_PROXY[bool].parent +if sys.version_info >= (2, 6): + _CONST_PROXY[bytes] = MANAGER.astng_from_class(bytes) # TODO : find a nicer way to handle this situation; we should at least # be able to avoid calling MANAGER.astng_from_class(const.value.__class__) |