diff Python/symtable.c @ 41717:9ad84070b22d

Merged revisions 55328-55341 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/p3yk ........ r55329 | brett.cannon | 2007-05-14 16:36:56 -0700 (Mon, 14 May 2007) | 3 lines Implement the removal of tuple parameter unpacking (PEP 3113). Thanks, Tony Lownds for the patch. ........ r55331 | neal.norwitz | 2007-05-14 16:40:30 -0700 (Mon, 14 May 2007) | 1 line Update to use Python 3.0 ........ r55332 | brett.cannon | 2007-05-14 16:47:18 -0700 (Mon, 14 May 2007) | 2 lines Mention PEP 3113. And thanks to Tony Lownds for the PEP 3113 patch. ........ r55333 | neal.norwitz | 2007-05-14 16:57:06 -0700 (Mon, 14 May 2007) | 1 line Fix exception printing (no more exceptions module) ........ r55334 | neal.norwitz | 2007-05-14 17:11:10 -0700 (Mon, 14 May 2007) | 1 line Remove popen* functions from os ........ r55335 | neal.norwitz | 2007-05-14 18:03:38 -0700 (Mon, 14 May 2007) | 1 line Get rid of most of popen. There are still some uses I need to cleanup. ........ r55336 | neal.norwitz | 2007-05-14 21:11:34 -0700 (Mon, 14 May 2007) | 1 line Remove a few more remnants of the compiler package ........ r55337 | neal.norwitz | 2007-05-14 22:28:27 -0700 (Mon, 14 May 2007) | 1 line Get test_[cx]pickle working on 64-bit platforms (avoid overflow int/long) ........
author Guido van Rossum <guido@python.org>
date Tue, 15 May 2007 18:46:22 +0000
parents e16c8e5c5ca4
children b29d71d43c80
line wrap: on
line diff
--- a/Python/symtable.c	Mon May 14 22:51:27 2007 +0000
+++ b/Python/symtable.c	Tue May 15 18:46:22 2007 +0000
@@ -180,10 +180,8 @@
 static int symtable_visit_comprehension(struct symtable *st, comprehension_ty);
 static int symtable_visit_keyword(struct symtable *st, keyword_ty);
 static int symtable_visit_slice(struct symtable *st, slice_ty);
-static int symtable_visit_params(struct symtable *st, asdl_seq *args, int top,
-                                 int annotations);
-static int symtable_visit_params_nested(struct symtable *st, asdl_seq *args,
-                                        int annotations);
+static int symtable_visit_params(struct symtable *st, asdl_seq *args);
+static int symtable_visit_argannotations(struct symtable *st, asdl_seq *args);
 static int symtable_implicit_arg(struct symtable *st, int pos);
 static int symtable_visit_annotations(struct symtable *st, stmt_ty s);
 
@@ -1328,79 +1326,51 @@
 }
 
 static int 
-symtable_visit_params(struct symtable *st, asdl_seq *args, int toplevel,
-                      int annotations)
+symtable_visit_params(struct symtable *st, asdl_seq *args)
 {
 	int i;
 
 	if (!args)
 		return -1;
 	
-        /* go through all the toplevel arguments first */
 	for (i = 0; i < asdl_seq_LEN(args); i++) {
 		arg_ty arg = (arg_ty)asdl_seq_GET(args, i);
-		if (arg->kind == SimpleArg_kind) {
-			if (!annotations) {
-				if (!symtable_add_def(st,
-				                      arg->v.SimpleArg.arg,
-				                      DEF_PARAM))
-					return 0;
-			}
-			else if (arg->v.SimpleArg.annotation)
-				VISIT(st, expr, arg->v.SimpleArg.annotation);
-		}
-		else if (arg->kind == NestedArgs_kind) {
-			if (toplevel && !annotations) {
-				if (!symtable_implicit_arg(st, i))
-					return 0;
-			}
-		}
-		else {
-		        PyErr_SetString(PyExc_SyntaxError,
-					"invalid expression in parameter list");
-		        PyErr_SyntaxLocation(st->st_filename,
-				             st->st_cur->ste_lineno);
-			return 0;
-		}
-	}
-
-	if (!toplevel) {
-		if (!symtable_visit_params_nested(st, args, annotations))
+		if (!symtable_add_def(st, arg->arg, DEF_PARAM))
 			return 0;
 	}
 
 	return 1;
 }
 
-static int
-symtable_visit_params_nested(struct symtable *st, asdl_seq *args,
-                             int annotations)
+static int 
+symtable_visit_argannotations(struct symtable *st, asdl_seq *args)
 {
 	int i;
+
+	if (!args)
+		return -1;
+	
 	for (i = 0; i < asdl_seq_LEN(args); i++) {
 		arg_ty arg = (arg_ty)asdl_seq_GET(args, i);
-		if (arg->kind == NestedArgs_kind &&
-		    !symtable_visit_params(st, arg->v.NestedArgs.args, 0,
-		                           annotations))
-			return 0;
+		if (arg->annotation)
+			VISIT(st, expr, arg->annotation);
 	}
 
 	return 1;
 }
 
-
 static int
 symtable_visit_annotations(struct symtable *st, stmt_ty s)
 {
 	arguments_ty a = s->v.FunctionDef.args;
 	
-	if (a->args && !symtable_visit_params(st, a->args, 1, 1))
+	if (a->args && !symtable_visit_argannotations(st, a->args))
 		return 0;
 	if (a->varargannotation)
 		VISIT(st, expr, a->varargannotation);
 	if (a->kwargannotation)
 		VISIT(st, expr, a->kwargannotation);
-	if (a->kwonlyargs && !symtable_visit_params(st, a->kwonlyargs, 1, 1))
+	if (a->kwonlyargs && !symtable_visit_argannotations(st, a->kwonlyargs))
 		return 0;
 	if (s->v.FunctionDef.returns)
 		VISIT(st, expr, s->v.FunctionDef.returns);
@@ -1413,9 +1383,9 @@
 	/* skip default arguments inside function block
 	   XXX should ast be different?
 	*/
-	if (a->args && !symtable_visit_params(st, a->args, 1, 0))
+	if (a->args && !symtable_visit_params(st, a->args))
 		return 0;
-	if (a->kwonlyargs && !symtable_visit_params(st, a->kwonlyargs, 1, 0))
+	if (a->kwonlyargs && !symtable_visit_params(st, a->kwonlyargs))
 		return 0;
 	if (a->vararg) {
 		if (!symtable_add_def(st, a->vararg, DEF_PARAM))
@@ -1427,8 +1397,6 @@
 			return 0;
 		st->st_cur->ste_varkeywords = 1;
 	}
-	if (a->args && !symtable_visit_params_nested(st, a->args, 0))
-		return 0;
 	return 1;
 }