Mailing List Archive

python/dist/src/Python bltinmodule.c,2.197.2.1,2.197.2.2 ceval.c,2.238.2.6,2.238.2.7
Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv7304

Modified Files:
Tag: release21-maint
bltinmodule.c ceval.c
Log Message:
Backport fixes for two nested scopes bugs.

frameobject.c: make sure free and cell vars make it into locals, which
makes eval work.

bltinmodule.c & ceval.c: make sure a code object with free variables
that is passed to exec or eval raises an exception.

Also duplicate the current trunk test suite in the 2.1 branch, except
for certain necessary changes: different warnings raised by 2.1, need
for __future__.



Index: bltinmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v
retrieving revision 2.197.2.1
retrieving revision 2.197.2.2
diff -C2 -d -r2.197.2.1 -r2.197.2.2
*** bltinmodule.c 23 May 2001 12:46:45 -0000 2.197.2.1
--- bltinmodule.c 20 Apr 2002 18:21:29 -0000 2.197.2.2
***************
*** 757,762 ****
return NULL;
}
! if (PyCode_Check(cmd))
return PyEval_EvalCode((PyCodeObject *) cmd, globals, locals);
if (!PyString_Check(cmd) &&
!PyUnicode_Check(cmd)) {
--- 757,768 ----
return NULL;
}
! if (PyCode_Check(cmd)) {
! if (PyCode_GetNumFree((PyCodeObject *)cmd) > 0) {
! PyErr_SetString(PyExc_TypeError,
! "code object passed to eval() may not contain free variables");
! return NULL;
! }
return PyEval_EvalCode((PyCodeObject *) cmd, globals, locals);
+ }
if (!PyString_Check(cmd) &&
!PyUnicode_Check(cmd)) {

Index: ceval.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v
retrieving revision 2.238.2.6
retrieving revision 2.238.2.7
diff -C2 -d -r2.238.2.6 -r2.238.2.7
*** ceval.c 28 Mar 2002 20:21:21 -0000 2.238.2.6
--- ceval.c 20 Apr 2002 18:21:29 -0000 2.238.2.7
***************
*** 3515,3518 ****
--- 3515,3523 ----
PyDict_SetItemString(globals, "__builtins__", f->f_builtins);
if (PyCode_Check(prog)) {
+ if (PyCode_GetNumFree((PyCodeObject *)prog) > 0) {
+ PyErr_SetString(PyExc_TypeError,
+ "code object passed to exec may not contain free variables");
+ return -1;
+ }
v = PyEval_EvalCode((PyCodeObject *) prog, globals, locals);
}