[Python-checkins] python/dist/src/Objects frameobject.c,2.61,2.62
jhylton@sourceforge.net
jhylton@sourceforge.net
2002年4月19日 21:46:57 -0700
Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv30827
Modified Files:
frameobject.c
Log Message:
Fix SF bug #505315: Make free and cell vars show up consistently in locals().
PyFrame_FastToLocals() and PyFrame_LocalsToFast() had a return if
f_nlocals was 0. I think this was a holdover from the pre 2.1 days
when regular locals were the only kind of local variables.
The change makes it possible to use a free variable in eval or exec if
it the variable is also used elsewhere in the same block, which is
what the documentation says.
Index: frameobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/frameobject.c,v
retrieving revision 2.61
retrieving revision 2.62
diff -C2 -d -r2.61 -r2.62
*** frameobject.c 13 Apr 2002 05:21:47 -0000 2.61
--- frameobject.c 20 Apr 2002 04:46:55 -0000 2.62
***************
*** 417,422 ****
}
}
- if (f->f_nlocals == 0)
- return;
map = f->f_code->co_varnames;
if (!PyDict_Check(locals) || !PyTuple_Check(map))
--- 417,420 ----
***************
*** 427,431 ****
if (j > f->f_nlocals)
j = f->f_nlocals;
! map_to_dict(map, j, locals, fast, 0);
if (f->f_ncells || f->f_nfreevars) {
if (!(PyTuple_Check(f->f_code->co_cellvars)
--- 425,430 ----
if (j > f->f_nlocals)
j = f->f_nlocals;
! if (f->f_nlocals)
! map_to_dict(map, j, locals, fast, 0);
if (f->f_ncells || f->f_nfreevars) {
if (!(PyTuple_Check(f->f_code->co_cellvars)
***************
*** 456,460 ****
locals = f->f_locals;
map = f->f_code->co_varnames;
! if (locals == NULL || f->f_code->co_nlocals == 0)
return;
if (!PyDict_Check(locals) || !PyTuple_Check(map))
--- 455,459 ----
locals = f->f_locals;
map = f->f_code->co_varnames;
! if (locals == NULL)
return;
if (!PyDict_Check(locals) || !PyTuple_Check(map))
***************
*** 465,469 ****
if (j > f->f_nlocals)
j = f->f_nlocals;
! dict_to_map(f->f_code->co_varnames, j, locals, fast, 0, clear);
if (f->f_ncells || f->f_nfreevars) {
if (!(PyTuple_Check(f->f_code->co_cellvars)
--- 464,469 ----
if (j > f->f_nlocals)
j = f->f_nlocals;
! if (f->f_nlocals)
! dict_to_map(f->f_code->co_varnames, j, locals, fast, 0, clear);
if (f->f_ncells || f->f_nfreevars) {
if (!(PyTuple_Check(f->f_code->co_cellvars)
***************
*** 475,479 ****
dict_to_map(f->f_code->co_freevars,
PyTuple_GET_SIZE(f->f_code->co_freevars),
! locals, fast + f->f_nlocals + f->f_ncells, 1, clear);
}
PyErr_Restore(error_type, error_value, error_traceback);
--- 475,480 ----
dict_to_map(f->f_code->co_freevars,
PyTuple_GET_SIZE(f->f_code->co_freevars),
! locals, fast + f->f_nlocals + f->f_ncells, 1,
! clear);
}
PyErr_Restore(error_type, error_value, error_traceback);