[Python-checkins] CVS: python/dist/src/Python ceval.c,2.230,2.231

Jeremy Hylton jhylton@usw-pr-cvs1.sourceforge.net
2001年3月12日 17:58:24 -0800


Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv30486/Python
Modified Files:
	ceval.c 
Log Message:
Variety of small INC/DECREF patches that fix reported memory leaks
with free variables. Thanks to Martin v. Loewis for finding two of
the problems. This fixes SF buf 405583.
There is also a C API change: PyFrame_New() is reverting to its
pre-2.1 signature. The change introduced by nested scopes was a
mistake. XXX Is this okay between beta releases?
cell_clear(), the GC helper, must decref its reference to break
cycles.
frame_dealloc() must dealloc all cell vars and free vars in addition
to locals.
eval_code2() setup code must INCREF cells it copies out of the
closure.
The STORE_DEREF opcode implementation must DECREF the object it passes
to PyCell_Set().
Index: ceval.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v
retrieving revision 2.230
retrieving revision 2.231
diff -C2 -r2.230 -r2.231
*** ceval.c	2001年02月16日 11:52:31	2.230
--- ceval.c	2001年03月13日 01:58:21	2.231
***************
*** 431,435 ****
 	f = PyFrame_New(tstate,			/*back*/
 			co,			/*code*/
! 			globals, locals, closure);
 	if (f == NULL)
 		return NULL;
--- 431,435 ----
 	f = PyFrame_New(tstate,			/*back*/
 			co,			/*code*/
! 			globals, locals);
 	if (f == NULL)
 		return NULL;
***************
*** 579,584 ****
 	if (f->f_nfreevars) {
 		int i;
! 		for (i = 0; i < f->f_nfreevars; ++i)
! 			freevars[f->f_ncells + i] = PyTuple_GET_ITEM(closure, i);
 	}
 
--- 579,587 ----
 	if (f->f_nfreevars) {
 		int i;
! 		for (i = 0; i < f->f_nfreevars; ++i) {
! 			PyObject *o = PyTuple_GET_ITEM(closure, i);
! 			Py_INCREF(o);
! 			freevars[f->f_ncells + i] = o;
! 		}
 	}
 
***************
*** 1663,1667 ****
 				break;
 			}
- 			Py_INCREF(w);
 			PUSH(w);
 			break;
--- 1666,1669 ----
***************
*** 1671,1674 ****
--- 1673,1677 ----
 			x = freevars[oparg];
 			PyCell_Set(x, w);
+ 			Py_DECREF(w);
 			continue;
 

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