[Python-Dev] Changing a value in a frame (for a debugger)

2007-02-06 Thread Fabio Zadrozny

Hi All,

I'm currently trying to change the value for a variable in the debugger
using:

frame = findFrame(thread_id, frame_id)
exec '%s=%s' % (attr, expression) in frame.f_globals, frame.f_locals

it works well when the frame for the change is the topmost frame, but fails
otherwise...

I found some references speaking about some issue with PyFrame_FastToLocals
which made it appear like this was not possible to do... so, basically, is
there some way to make this work from python (changing a variable having a
given frame) or not?

Thanks,

Fabio
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Changing a value in a frame (for a debugger)

2007-02-06 Thread Greg Ewing
Fabio Zadrozny wrote:

> frame = findFrame(thread_id, frame_id)
> exec '%s=%s' % (attr, expression) in frame.f_globals, frame.f_locals

The locals of a function are actually stored in an array.
When you access them as a dict using locals(), all you
get is a dict containing a copy of their current values.
Modifying that dict doesn't affect the underlying array.

It seems that reading the f_locals of a frame does the
same thing. To modify the locals, you would need to poke
values into the original array -- but it doesn't seem
to be exposed to Python.

So it looks like you're out of luck.

--
Greg
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com