[Python-checkins] CVS: python/dist/src/Python compile.c,2.114,2.115

Peter Schneider-Kamp python-dev@python.org
Wed, 12 Jul 2000 23:15:07 -0700


Update of /cvsroot/python/python/dist/src/Python
In directory slayer.i.sourceforge.net:/tmp/cvs-serv17802

Modified Files:
	compile.c 
Log Message:

raise error on duplicate function arguments

example:

>>> def f(a,a):print a
...
SyntaxError: duplicate argument in function definition



Index: compile.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v
retrieving revision 2.114
retrieving revision 2.115
diff -C2 -r2.114 -r2.115
*** compile.c	2000/07/09 03:09:56	2.114
--- compile.c	2000/07/13 06:15:04	2.115
***************
*** 3093,3096 ****
--- 3093,3097 ----
  		node *fp;
  		char *name;
+ 		PyObject *nameval;
  		if (TYPE(ch) == STAR || TYPE(ch) == DOUBLESTAR)
  			break;
***************
*** 3104,3108 ****
  			complex = 1;
  		}
! 		com_newlocal(c, name);
  		c->c_argcount++;
  		if (++i >= nch)
--- 3105,3117 ----
  			complex = 1;
  		}
! 		nameval = PyString_InternFromString(name);
! 		if (nameval == NULL) {
! 			c->c_errors++;
! 		}
!                 if (PyDict_GetItem(c->c_locals, nameval)) {
! 			com_error(c, PyExc_SyntaxError,"duplicate argument in function definition");
! 		}
! 		com_newlocal_o(c, nameval);
! 		Py_DECREF(nameval);
  		c->c_argcount++;
  		if (++i >= nch)