[Python-Dev] compile.c: problem with duplicate argument bugfix

Peter Schneider-Kamp peter@schneider-kamp.de
Sat, 08 Jul 2000 19:27:50 +0000


This is a multi-part message in MIME format.
--------------EA0D50E02DA38B730060AB92
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I am trying to fix the duplicate argument bug in the compiler.

[example]
>>> def f(a,a): print a
... 
>>> f(1,2)
2
[/example]

My problem is that I get a segfault whenever I try to raise an
com_error from com_arglist. I have attached a very short patch.

Thanks for any hint,
Peter

P.S.: Is this on topic for python-dev? If not, where should
      I send such a request?
--
Peter Schneider-Kamp          ++47-7388-7331
Herman Krags veg 51-11        mailto:peter@schneider-kamp.de
N-7050 Trondheim              http://schneider-kamp.de
--------------EA0D50E02DA38B730060AB92
Content-Type: text/plain; charset=us-ascii;
 name="compile_funcdef.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="compile_funcdef.patch"

diff -c -d -T --recursive python/dist/src/Python/compile.c python-mod/dist/src/Python/compile.c
*** python/dist/src/Python/compile.c	Mon Jul  3 21:39:47 2000
--- python-mod/dist/src/Python/compile.c	Sat Jul  8 19:13:42 2000
***************
*** 3102,3109 ****
 				name = nbuf;
 				sprintf(nbuf, ".%d", i);
 				complex = 1;
 			}
!			com_newlocal(c, name);
 			c->c_argcount++;
 			if (++i >= nch)
 				break;
--- 3103,3120 ----
 				name = nbuf;
 				sprintf(nbuf, ".%d", i);
 				complex = 1;
+	                }
+	                
+			nameval = PyString_InternFromString(name);
+			if (nameval == NULL) {
+				c->c_errors++;
 			}
!			if (PyDict_GetItem(c->c_locals, nameval)) {
!				com_error(c, PyExc_SyntaxError,"double identifier in function definition");
!			}
!			com_newlocal_o(c, nameval);
!			Py_DECREF(nameval);
!	                
 			c->c_argcount++;
 			if (++i >= nch)
 				break;

--------------EA0D50E02DA38B730060AB92--