[Compiler-sig] Fix for default args causes an unrelated segfault

logistix logistix@cathoderaymission.net
Sun, 25 May 2003 18:59:49 -0400


This is a multi-part message in MIME format.

------=_NextPart_000_0001_01C322EF.D16A2B30
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: 7bit

One of the big problems preventing successful compilation of site.py was
improper handing of keyword arguments:

>>> def foo(a,b=1):print a,b
>>> foo(1)

This also prevented me from being able to import dis to look at function
objects.  I tracked down the problem.  MAKE_FUNCTION was getting sent
the wrong parameter.

However, the fix causes an unrelated segfault.  I tracked the segfault
down to the sre package.  This gets imported via the warnings module,
which in turn gets imported whether or not you use the "-S" flag when
running python.  Simply renaming "re.py" to "_re.py" and killing the
existing .pyc file eliminates the segfault.  Previously, "site.py"
failed before it got the opportunity to import re, preventing the error
from being raised.

Since that's all it takes to eliminate the segfault, I feel confortable
in my patch.  But I also didn't want to shoot a patch to SourceForge
that breaks a working build.

So, here you go,

-Grant

P.S. Is there any way to temporarily shut off the compile trace at the
interactive prompt?

------=_NextPart_000_0001_01C322EF.D16A2B30
Content-Type: application/octet-stream;
	name="newcompile.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="newcompile.diff"

Index: newcompile.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/Attic/newcompile.c,v
retrieving revision 1.1.2.53
diff -r1.1.2.53 newcompile.c
717c717
< 	ADDOP_I(c, MAKE_FUNCTION, c->u->u_argcount);
---
> 	ADDOP_I(c, MAKE_FUNCTION, asdl_seq_LEN(args->defaults));

------=_NextPart_000_0001_01C322EF.D16A2B30--