summaryrefslogtreecommitdiff
path: root/rebuilder.py
diff options
context:
space:
mode:
authorJulien Cristau <julien.cristau@logilab.fr>2013-07-18 22:57:13 +0200
committerJulien Cristau <julien.cristau@logilab.fr>2013-07-18 22:57:13 +0200
commitba2393d46474b72bb04b50dce629a9fa2bd6c7c5 (patch)
tree499d0d7df051006e30b85fff4cc9eae87e0a0294 /rebuilder.py
parent5b0746a34b39a9c8d0fb00a1277fd844666a247d (diff)
downloadastroid-git-ba2393d46474b72bb04b50dce629a9fa2bd6c7c5.tar.gz
Add support for py3k's keyword only arguments
PEP 3102
Diffstat (limited to 'rebuilder.py')
-rw-r--r--rebuilder.py10
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()