summaryrefslogtreecommitdiffstats
path: root/Lib/compiler/symbols.py
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2006-12-28 06:47:50 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2006-12-28 06:47:50 (GMT)
commitc150536b5efadf71fcb4187cad7258be7268e157 (patch)
treeaeb17f5e0ecc6cc8ccdecb2b64e3f46a0a3af85c /Lib/compiler/symbols.py
parentf6657e67b3cf89649d14d9012b3964a3490d45b0 (diff)
downloadcpython-c150536b5efadf71fcb4187cad7258be7268e157.zip
cpython-c150536b5efadf71fcb4187cad7258be7268e157.tar.gz
cpython-c150536b5efadf71fcb4187cad7258be7268e157.tar.bz2
PEP 3107 - Function Annotations thanks to Tony Lownds
Diffstat (limited to 'Lib/compiler/symbols.py')
-rw-r--r--Lib/compiler/symbols.py21
1 files changed, 14 insertions, 7 deletions
diff --git a/Lib/compiler/symbols.py b/Lib/compiler/symbols.py
index 7ddf42c..3585efc 100644
--- a/Lib/compiler/symbols.py
+++ b/Lib/compiler/symbols.py
@@ -233,7 +233,12 @@ class SymbolVisitor:
if parent.nested or isinstance(parent, FunctionScope):
scope.nested = 1
self.scopes[node] = scope
- self._do_args(scope, node.argnames)
+
+ args = node.arguments
+ for kwonly in node.kwonlyargs:
+ args.append(kwonly.arg)
+ self._do_arguments(scope, args)
+
self.visit(node.code, scope)
self.handle_free_vars(scope, parent)
@@ -275,16 +280,18 @@ class SymbolVisitor:
if parent.nested or isinstance(parent, FunctionScope):
scope.nested = 1
self.scopes[node] = scope
- self._do_args(scope, node.argnames)
+ self._do_arguments(scope, node.arguments)
self.visit(node.code, scope)
self.handle_free_vars(scope, parent)
- def _do_args(self, scope, args):
- for name in args:
- if type(name) == types.TupleType:
- self._do_args(scope, name)
+ def _do_arguments(self, scope, arguments):
+ for node in arguments:
+ if isinstance(node, ast.SimpleArg):
+ scope.add_param(node.name)
+ if node.annotation:
+ self.visit(node.annotation, scope)
else:
- scope.add_param(name)
+ self._do_arguments(scope, node.args)
def handle_free_vars(self, scope, parent):
parent.add_child(scope)