[Python-checkins] CVS: python/dist/src/Python compile.c,2.186,2.187
Jeremy Hylton
jhylton@users.sourceforge.net
Mon, 19 Mar 2001 12:38:08 -0800
Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv3465/Python
Modified Files:
compile.c
Log Message:
Fix crashes in nested list comprehensions
SF bugs 409230 and 407800
Also remove bogus list comp code from symtable_assign().
Index: compile.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v
retrieving revision 2.186
retrieving revision 2.187
diff -C2 -r2.186 -r2.187
*** compile.c 2001/03/02 03:30:41 2.186
--- compile.c 2001/03/19 20:38:06 2.187
***************
*** 1,3 ****
-
/* Compile an expression node to intermediate code */
--- 1,2 ----
***************
*** 4819,4825 ****
case listmaker:
if (NCH(n) > 1 && TYPE(CHILD(n, 1)) == list_for) {
symtable_list_comprehension(st, CHILD(n, 1));
! n = CHILD(n, 0);
! goto loop;
}
case atom:
--- 4818,4826 ----
case listmaker:
if (NCH(n) > 1 && TYPE(CHILD(n, 1)) == list_for) {
+ st->st_tmpname++;
symtable_list_comprehension(st, CHILD(n, 1));
! symtable_node(st, CHILD(n, 0));
! st->st_tmpname--;
! return;
}
case atom:
***************
*** 5018,5022 ****
char tmpname[12];
! sprintf(tmpname, "_[%d]", ++st->st_tmpname);
symtable_add_def(st, tmpname, DEF_LOCAL);
symtable_assign(st, CHILD(n, 1), 0);
--- 5019,5023 ----
char tmpname[12];
! sprintf(tmpname, "_[%d]", st->st_tmpname);
symtable_add_def(st, tmpname, DEF_LOCAL);
symtable_assign(st, CHILD(n, 1), 0);
***************
*** 5024,5028 ****
if (NCH(n) == 5)
symtable_node(st, CHILD(n, 4));
- --st->st_tmpname;
}
--- 5025,5028 ----
***************
*** 5096,5102 ****
return;
case listmaker:
! if (NCH(n) > 1 && TYPE(CHILD(n, 1)) == list_for)
! symtable_list_comprehension(st, CHILD(n, 1));
! else {
for (i = 0; i < NCH(n); i += 2)
symtable_assign(st, CHILD(n, i), flag);
--- 5096,5104 ----
return;
case listmaker:
! if (NCH(n) > 1 && TYPE(CHILD(n, 1)) == list_for) {
! /* XXX This is an error, but the next pass
! will catch it. */
! return;
! } else {
for (i = 0; i < NCH(n); i += 2)
symtable_assign(st, CHILD(n, i), flag);