[Python-checkins] python/dist/src/Python newcompile.c, 1.1.2.73, 1.1.2.74

jhylton at users.sourceforge.net jhylton at users.sourceforge.net
Sun Feb 15 23:07:27 EST 2004


Update of /cvsroot/python/python/dist/src/Python
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3381
Modified Files:
 Tag: ast-branch
	newcompile.c 
Log Message:
Extend compute_code_flags() to set CO_NOFREE.
Index: newcompile.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/Attic/newcompile.c,v
retrieving revision 1.1.2.73
retrieving revision 1.1.2.74
diff -C2 -d -r1.1.2.73 -r1.1.2.74
*** newcompile.c	15 Feb 2004 04:19:28 -0000	1.1.2.73
--- newcompile.c	16 Feb 2004 04:07:24 -0000	1.1.2.74
***************
*** 2616,2620 ****
 {
 	PySTEntryObject *ste = c->u->u_ste;
! 	int flags = 0;
 	if (ste->ste_type != ModuleBlock)
 		flags |= CO_NEWLOCALS;
--- 2616,2620 ----
 {
 	PySTEntryObject *ste = c->u->u_ste;
! 	int flags = 0, n;
 	if (ste->ste_type != ModuleBlock)
 		flags |= CO_NEWLOCALS;
***************
*** 2631,2634 ****
--- 2631,2646 ----
 	if (ste->ste_varkeywords)
 		flags |= CO_VARKEYWORDS;
+ 	n = PyDict_Size(c->u->u_freevars);
+ 	if (n < 0)
+ 	 return -1;
+ 	if (n == 0) {
+ 	 n = PyDict_Size(c->u->u_cellvars);
+ 	 if (n < 0)
+ 		return -1;
+ 	 if (n == 0) {
+ 		flags |= CO_NOFREE;
+ 	 }
+ 	}
+ 
 	return flags;
 }
***************
*** 2645,2649 ****
 	PyObject *freevars = NULL;
 	PyObject *cellvars = NULL;
! 	int nlocals;
 
 	consts = dict_keys_inorder(c->u->u_consts, 0);
--- 2657,2661 ----
 	PyObject *freevars = NULL;
 	PyObject *cellvars = NULL;
! 	int nlocals, flags;
 
 	consts = dict_keys_inorder(c->u->u_consts, 0);
***************
*** 2662,2667 ****
 
 nlocals = PyDict_Size(c->u->u_varnames);
 	co = PyCode_New(c->u->u_argcount, nlocals, stackdepth(c),
! 			compute_code_flags(c),
 			a->a_bytecode, consts, names, varnames,
 			freevars, cellvars,
--- 2674,2682 ----
 
 nlocals = PyDict_Size(c->u->u_varnames);
+ 	flags = compute_code_flags(c);
+ 	if (flags < 0)
+ 	 goto error;
 	co = PyCode_New(c->u->u_argcount, nlocals, stackdepth(c),
! 			flags,
 			a->a_bytecode, consts, names, varnames,
 			freevars, cellvars,


More information about the Python-checkins mailing list

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