summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--_nodes_ast.py9
-rw-r--r--as_string.py5
-rw-r--r--node_classes.py5
-rw-r--r--nodes.py4
4 files changed, 20 insertions, 3 deletions
diff --git a/_nodes_ast.py b/_nodes_ast.py
index ecd9d46b..e862a79e 100644
--- a/_nodes_ast.py
+++ b/_nodes_ast.py
@@ -637,6 +637,15 @@ class TreeRebuilder(RebuildVisitor):
newnode.set_line_info(newnode.last_child())
return newnode
+ def visit_starred(self, node, parent):
+ """visit a Starred node and return a new instance of it"""
+ newnode = new.Starred()
+ _lineno_parent(node, newnode, parent)
+ newnode.value = self.visit(node.value, newnode)
+ newnode.set_line_info(newnode.last_child())
+ return newnode
+
+
def visit_tryexcept(self, node, parent):
"""visit a TryExcept node by returning a fresh instance of it"""
newnode = new.TryExcept()
diff --git a/as_string.py b/as_string.py
index 781aa49d..02a028a0 100644
--- a/as_string.py
+++ b/as_string.py
@@ -407,7 +407,7 @@ class AsStringVisitor3k(AsStringVisitor):
excs = 'except %s' % node.type.accept(self)
else:
excs = 'except'
- return '%s:\n%s' % (excs, self._stmt_list(node.body))
+ return '%s:\n%s' % (excs, self._stmt_list(node.body))
def visit_raise(self, node):
"""return an astng.Raise node as string"""
@@ -418,6 +418,9 @@ class AsStringVisitor3k(AsStringVisitor):
return 'raise %s' % node.exc.accept(self)
return 'raise'
+ def visit_starred(self, node):
+ """return Starred node as string"""
+ return "*" + node.value.accept(self)
if sys.version_info >= (3, 0):
AsStringVisitor = AsStringVisitor3k
diff --git a/node_classes.py b/node_classes.py
index 58f91f43..133836da 100644
--- a/node_classes.py
+++ b/node_classes.py
@@ -714,6 +714,11 @@ class Slice(NodeNG):
upper = None
step = None
+class Starred(NodeNG):
+ """class representing a Starred node"""
+ _astng_fields = ('value',)
+ value = None
+
class Subscript(NodeNG):
"""class representing a Subscript node"""
diff --git a/nodes.py b/nodes.py
index 4d854ffc..afb6664c 100644
--- a/nodes.py
+++ b/nodes.py
@@ -56,7 +56,7 @@ from logilab.astng.node_classes import Arguments, AssAttr, Assert, Assign, \
Comprehension, Const, Continue, Decorators, DelAttr, DelName, Delete, \
Dict, Discard, Ellipsis, EmptyNode, ExceptHandler, Exec, ExtSlice, For, \
From, Getattr, Global, If, IfExp, Import, Index, Keyword, \
- List, Name, Pass, Print, Raise, Return, Set, Slice, Subscript, \
+ List, Name, Pass, Print, Raise, Return, Set, Slice, Starred, Subscript, \
TryExcept, TryFinally, Tuple, UnaryOp, While, With, Yield, \
const_factory
from logilab.astng.scoped_nodes import Module, GenExpr, Lambda, DictComp, \
@@ -78,7 +78,7 @@ ALL_NODE_CLASSES = (
Module,
Pass, Print,
Raise, Return,
- Set, SetComp, Slice, Subscript,
+ Set, SetComp, Slice, Starred, Subscript,
TryExcept, TryFinally, Tuple,
UnaryOp,
While, With,