diff options
-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__) |