[ python-Feature Requests-1654367 ] [PATCH] Debuggers need a way to change the locals of a frame
SourceForge.net
noreply at sourceforge.net
Thu Feb 8 09:38:32 CET 2007
Feature Requests item #1654367, was opened at 2007-02-07 18:12
Message generated for change (Comment added) made by loewis
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1654367&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: Python 2.6
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Fabio Zadrozny (fabioz)
Assigned to: Nobody/Anonymous (nobody)
Summary: [PATCH] Debuggers need a way to change the locals of a frame
Initial Comment:
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
----------------------------------------------------------------------
>Comment By: Martin v. Löwis (loewis)
Date: 2007-02-08 09:38
Message:
Logged In: YES
user_id=21627
Originator: NO
Why don't you set the clear parameter to 1?
Please do submit a patch, you can use 'diff -ur' to create a recursive
unified diff between source trees. Please also try to come up with a patch
to the documentation.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1654367&group_id=5470
More information about the Python-bugs-list
mailing list