[Python-Dev] test_inspect fails again: segfault in compile
Michael Hudson
mwh21@cam.ac.uk
11 Feb 2001 16:23:25 +0000
Ka-Ping Yee <ping@lfw.org> writes:
> After further testing, it seems to come down to this:
>
> Python 2.1a2 (#22, Feb 10 2001, 16:15:14)
> [GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2
> Type "copyright", "credits" or "license" for more information.
> >>> def spam(a, b): pass
> ...
> >>> def spam(a=3, b): pass
> ...
> SyntaxError: non-default argument follows default argument
> >>> def spam(a=3, b=4): pass
> ...
> >>> def spam(a, (b,)): pass
> ...
> >>> def spam(a=3, (b,)): pass
> ...
> Segmentation fault (core dumped)
>
> Python 2.1a2 (#22, Feb 10 2001, 16:15:14)
> [GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2
> Type "copyright", "credits" or "license" for more information.
> >>> def spam(a=3, (b,)=(4,)): pass
> ...
> Segmentation fault (core dumped)
>
Try this:
Index: compile.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v
retrieving revision 2.162
diff -c -r2.162 compile.c
*** compile.c 2001/02/09 22:55:26 2.162
--- compile.c 2001/02/11 16:19:02
***************
*** 4629,4635 ****
for (j = 0; j <= complex; j++) {
c = CHILD(n, j);
if (TYPE(c) == COMMA)
! c = CHILD(n, ++j);
if (TYPE(CHILD(c, 0)) == LPAR)
symtable_params_fplist(st, CHILD(c, 1));
}
--- 4629,4637 ----
for (j = 0; j <= complex; j++) {
c = CHILD(n, j);
if (TYPE(c) == COMMA)
! c = CHILD(n, ++j);
! else if (TYPE(c) == EQUAL)
! c = CHILD(n, j += 3);
if (TYPE(CHILD(c, 0)) == LPAR)
symtable_params_fplist(st, CHILD(c, 1));
}
Clearly there should be a test for this - where? test_extcall isn't
really appropriate, but I can't think of a better place. Maybe it
should be renamed to test_funcall.py and then a test for this can go
in.
Cheers,
M.
--
Some people say that a monkey would bang out the complete works
of Shakespeare on a typewriter give an unlimited amount of time.
In the meantime, what they would probably produce is a valid
sendmail configuration file. -- Nicholas Petreley