This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author fabioz
Recipients
Date 2007-02-07.17:12:28
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
Debuggers need a way to change the local variables in a given frame... currently, this works only if this change is done in the topmost frame (and under certain circumstances), but it should work for any frame.

Initial discussion at:
http://mail.python.org/pipermail/python-dev/2007-February/070884.html

Apparently, the problem is the order in which PyFrame_LocalsToFast / PyFrame_FastToLocals is called.

The proposed solution to this is having a savelocals() method in the frame object and have it reflect the changes in its returned dict into its locals. It will simply enable users to call PyFrame_LocalsToFast externally after a change, to be sure that it will not be changed (and it must be done before another call to PyFrame_LocalsToFast -- which I don't see as a large problem, because it is of restrict use -- mainly for debuggers).


--------- frameobject.c Patch part 1: -----------------

static PyObject *
PyFrame_SaveLocals(PyFrameObject *f)
{
    PyFrame_LocalsToFast(f, 0);
	Py_INCREF(Py_None);
	return Py_None;
}

static PyMethodDef frame_methodlist[] = {
    {"savelocals", (PyCFunction)PyFrame_SaveLocals, METH_NOARGS,
     "After a change in f_locals, this method should be called to save the changes internally."
    },
    {NULL}  /* Sentinel */
};


---------- frameobject.c Patch part 2: ---------------
Add to PyTypeObject PyFrame_Type:

frame_methodlist,/* tp_methods */

------------------ end patch -------------------------

I'm sorry that this is not in an actual patch format... but as I didn't get it from the cvs, it is easier for me to explain it (as it is a rather small patch).

Attached is a test-case for this patch.

Thanks, 

Fabio
History
Date User Action Args
2007-08-23 16:12:32adminlinkissue1654367 messages
2007-08-23 16:12:32admincreate