Index: Include/frameobject.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/frameobject.h,v retrieving revision 2.37 diff -c -r2.37 frameobject.h *** Include/frameobject.h 11 Sep 2002 15:36:31 -0000 2.37 --- Include/frameobject.h 8 Jan 2004 17:12:22 -0000 *************** *** 69,74 **** --- 69,75 ---- PyAPI_FUNC(void) PyFrame_LocalsToFast(PyFrameObject *, int); PyAPI_FUNC(void) PyFrame_FastToLocals(PyFrameObject *); + PyAPI_FUNC(void) PyFrame_BlockLocalsOnly(PyFrameObject *); #ifdef __cplusplus } Index: Objects/frameobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/frameobject.c,v retrieving revision 2.76 diff -c -r2.76 frameobject.c *** Objects/frameobject.c 21 Oct 2003 18:14:20 -0000 2.76 --- Objects/frameobject.c 8 Jan 2004 17:12:23 -0000 *************** *** 798,803 **** --- 798,827 ---- PyErr_Restore(error_type, error_value, error_traceback); } + void + PyFrame_BlockLocalsOnly(PyFrameObject *f) + { + /* Remove the free variables from f->f_locals. */ + PyObject* dict; + PyObject* map; + int j; + if (f->f_nfreevars) { + map = f->f_code->co_freevars; + if (!PyTuple_Check(map)) + return; + dict = f->f_locals; + if (dict == NULL) + return; + for (j = PyTuple_GET_SIZE(map); --j >= 0; ) { + PyObject *key = PyTuple_GET_ITEM(map, j); + if (PyDict_GetItem(dict, key) != NULL) { + if (PyDict_DelItem(dict, key) < 0) + PyErr_Clear(); + } + } + } + } + /* Clear out the free list */ void Index: Python/ceval.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v retrieving revision 2.373 diff -c -r2.373 ceval.c *** Python/ceval.c 20 Nov 2003 01:44:58 -0000 2.373 --- Python/ceval.c 8 Jan 2004 17:12:26 -0000 *************** *** 1608,1613 **** --- 1608,1614 ---- break; case LOAD_LOCALS: + PyFrame_BlockLocalsOnly(f); if ((x = f->f_locals) == NULL) { PyErr_SetString(PyExc_SystemError, "no locals"); *************** *** 4087,4093 **** Py_XDECREF(tmp); } if (plain) ! PyFrame_LocalsToFast(f, 0); if (v == NULL) return -1; Py_DECREF(v); --- 4088,4094 ---- Py_XDECREF(tmp); } if (plain) ! PyFrame_LocalsToFast(f, 1); if (v == NULL) return -1; Py_DECREF(v); Index: Doc/ref/ref4.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref4.tex,v retrieving revision 1.37 diff -c -r1.37 ref4.tex *** Doc/ref/ref4.tex 11 Dec 2003 19:45:53 -0000 1.37 --- Doc/ref/ref4.tex 8 Jan 2004 17:12:27 -0000 *************** *** 112,120 **** A class definition is an executable statement that may use and define names. These references follow the normal rules for name resolution. ! The namespace of the class definition becomes the attribute dictionary ! of the class. Names defined at the class scope are not visible in ! methods. \subsection{Interaction with dynamic features \label{dynamic-features}} --- 112,120 ---- A class definition is an executable statement that may use and define names. These references follow the normal rules for name resolution. ! The local variables of the class definition block becomes the attribute ! dictionary of the class. Names defined at the class scope are not ! visible in methods. \subsection{Interaction with dynamic features \label{dynamic-features}}