diff options
author | Emile Anclin <emile.anclin@logilab.fr> | 2010-10-28 16:07:24 +0200 |
---|---|---|
committer | Emile Anclin <emile.anclin@logilab.fr> | 2010-10-28 16:07:24 +0200 |
commit | 7dad421fabf708e96eab40f8327ce8cd46e900ae (patch) | |
tree | d92116586707b70fd1b8deb7eb0e1fe97e864370 | |
parent | 215f5df431c2d213bfeb250f575dbec806678149 (diff) | |
download | astroid-git-7dad421fabf708e96eab40f8327ce8cd46e900ae.tar.gz |
py3k : introduce Nonlocal node
-rw-r--r-- | as_string.py | 4 | ||||
-rw-r--r-- | node_classes.py | 9 | ||||
-rw-r--r-- | nodes.py | 4 |
3 files changed, 15 insertions, 2 deletions
diff --git a/as_string.py b/as_string.py index 02a028a0..76051111 100644 --- a/as_string.py +++ b/as_string.py @@ -409,6 +409,10 @@ class AsStringVisitor3k(AsStringVisitor): excs = 'except' return '%s:\n%s' % (excs, self._stmt_list(node.body)) + def visit_nonlocal(self, node): + """return an astng.Nonlocal node as string""" + return 'nonlocal %s' % ', '.join(node.names) + def visit_raise(self, node): """return an astng.Raise node as string""" if node.exc: diff --git a/node_classes.py b/node_classes.py index 133836da..95a3a36b 100644 --- a/node_classes.py +++ b/node_classes.py @@ -656,6 +656,15 @@ class List(NodeNG, Instance, ParentAssignTypeMixin): return self.elts +class Nonlocal(StmtMixIn, NodeNG): + """class representing a Nonlocal node""" + + def __init__(self, names): + self.names = names + + def _infer_name(self, frame, name): + return name + class Pass(StmtMixIn, NodeNG): """class representing a Pass node""" @@ -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, Starred, Subscript, \ + List, Name, Nonlocal, 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, \ @@ -74,7 +74,7 @@ ALL_NODE_CLASSES = ( If, IfExp, Import, Index, Keyword, Lambda, List, ListComp, - Name, + Name, Nonlocal, Module, Pass, Print, Raise, Return, |