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

Thomas Wouters thomas@xs4all.net
Mon, 10 Jul 2000 00:26:44 +0200

On Sun, Jul 09, 2000 at 11:17:44PM +0000, Peter Schneider-Kamp wrote:

> While "slaving away" on the Modules/ directory (thanks for
> the term - it made my day <wink>), I still haven't got a
> clue why Python crashes on me when I throw an error on
> duplicate arguments like in:

> >>> def f(a, a): print a
> segfault

> Any help is again appreciated.

Hm, strange. It works fine here. Do you get the segfault every time ?
Anyway, a possible problem is that PyString_InternFromString might return
NULL, and you later PyDict_GetItem() with it (not sure if that's a problem),
and you pass it to com_newlocal_o (not sure if that's a problem either), and
then you Py_DECREF it. And if you pass NULL to that macro you do have a
problem :) You should use Py_XDECREF() if you aren't sure wether the object
is NULL or not.

If your python left a corefile, you can easily find out if that was the
problem by using gdb on it. 'gdb ./python core', wait 'till it finishes
loading, and type 'bt'. It should give you reversed (from a python point of
view) backtrace from the time of the crash.

> !			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);

Thomas Wouters <thomas@xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!