[Python-checkins] python/dist/src/Python ceval.c, 2.314.2.4, 2.314.2.5

jhylton at users.sourceforge.net jhylton at users.sourceforge.net
Wed Apr 21 01:58:25 EDT 2004


Update of /cvsroot/python/python/dist/src/Python
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19105
Modified Files:
 Tag: ast-branch
	ceval.c 
Log Message:
Simplify hairy code to initialize cell variables.
The old code depended on the order in which the old compiler put names
into co_cellvars. The order is different with the new compiler, which
caused a bunch of test failures (e.g. test_userdict) when an argument
was also a cell variable.
In comment, note that it might be a good idea for the compiler to
generate names in a certain order. On the other hand, it's hard to
imagine a practical case where this would make a difference.
Index: ceval.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v
retrieving revision 2.314.2.4
retrieving revision 2.314.2.5
diff -C2 -d -r2.314.2.4 -r2.314.2.5
*** ceval.c	26 Mar 2004 18:17:31 -0000	2.314.2.4
--- ceval.c	21 Apr 2004 05:58:08 -0000	2.314.2.5
***************
*** 2574,2583 ****
 			nargs++;
 
! 		/* Check for cells that shadow args */
! 		for (i = 0; i < f->f_ncells && j < nargs; ++i) {
 			cellname = PyString_AS_STRING(
 				PyTuple_GET_ITEM(co->co_cellvars, i));
 			found = 0;
! 			while (j < nargs) {
 				argname = PyString_AS_STRING(
 					PyTuple_GET_ITEM(co->co_varnames, j));
--- 2574,2589 ----
 			nargs++;
 
! 		/* Initialize each cell var, taking into account
! 		 cell vars that are initialized from arguments.
! 
! 		 Should arrange for the compiler to put cellvars
! 		 that are arguments at the beginning of the cellvars
! 		 list so that we can march over it more efficiently?
! 		*/
! 		for (i = 0; i < f->f_ncells; ++i) {
 			cellname = PyString_AS_STRING(
 				PyTuple_GET_ITEM(co->co_cellvars, i));
 			found = 0;
! 			for (j = 0; j < nargs; j++) {
 				argname = PyString_AS_STRING(
 					PyTuple_GET_ITEM(co->co_varnames, j));
***************
*** 2590,2594 ****
 					break;
 				}
- 				j++;
 			}
 			if (found == 0) {
--- 2596,2599 ----
***************
*** 2599,2610 ****
 			}
 		}
- 		/* Initialize any that are left */
- 		while (i < f->f_ncells) {
- 			c = PyCell_New(NULL);
- 			if (c == NULL)
- 				goto fail;
- 			SETLOCAL(f->f_nlocals + i, c);
- 			i++;
- 		}
 	}
 	if (f->f_nfreevars) {
--- 2604,2607 ----


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /