diff options
author | Julien Cristau <julien.cristau@logilab.fr> | 2013-07-18 22:57:13 +0200 |
---|---|---|
committer | Julien Cristau <julien.cristau@logilab.fr> | 2013-07-18 22:57:13 +0200 |
commit | ba2393d46474b72bb04b50dce629a9fa2bd6c7c5 (patch) | |
tree | 499d0d7df051006e30b85fff4cc9eae87e0a0294 /rebuilder.py | |
parent | 5b0746a34b39a9c8d0fb00a1277fd844666a247d (diff) | |
download | astroid-git-ba2393d46474b72bb04b50dce629a9fa2bd6c7c5.tar.gz |
Add support for py3k's keyword only arguments
PEP 3102
Diffstat (limited to 'rebuilder.py')
-rw-r--r-- | rebuilder.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/rebuilder.py b/rebuilder.py index e06adeaf..cf92da09 100644 --- a/rebuilder.py +++ b/rebuilder.py @@ -185,6 +185,8 @@ class TreeRebuilder(object): newnode.args = [self.visit(child, newnode) for child in node.args] self.asscontext = None newnode.defaults = [self.visit(child, newnode) for child in node.defaults] + newnode.kwonlyargs = [] + newnode.kw_defaults = [] newnode.vararg = node.vararg newnode.kwarg = node.kwarg # save argument names in locals: @@ -836,6 +838,14 @@ class TreeRebuilder3k(TreeRebuilder): # XXX or we should instead introduce a Arg node in astroid ? return self.visit_assname(node, parent, node.arg) + def visit_arguments(self, node, parent): + newnode = super(TreeRebuilder3k, self).visit_arguments(node, parent) + self.asscontext = "Ass" + newnode.kwonlyargs = [self.visit(child, newnode) for child in node.kwonlyargs] + self.asscontext = None + newnode.kw_defaults = [self.visit(child, newnode) if child else None for child in node.kw_defaults] + return newnode + def visit_excepthandler(self, node, parent): """visit an ExceptHandler node by returning a fresh instance of it""" newnode = new.ExceptHandler() |