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

Phillip J. Eby pje at telecommunity.com
Wed Feb 7 18:47:00 CET 2007


At 08:11 AM 2/7/2007 -0200, Fabio Zadrozny wrote:
>Would it be ok to add a feature request for that? I initially thought it 
>was completely read-only, but I find it strange that it affects the 
>topmost frame correctly (so, it seems that even though I get a copy, when 
>I alter that copy on the topmost frame it affects it correctly)... anyone 
>has a clue why that happens?

The code that calls the debugging hook calls PyFrame_FastToLocals() before 
invoking the debugger, and then PyFrame_LocalsToFast() afterwards.  Thus, 
the interrupted frame can have its locals modified, but no others can.

In order for this to work on other frames, you'd have to explicitly call 
PyFrame_FastToLocals(frame, 1) -- which you could probably do with ctypes 
or a C extension.



More information about the Python-Dev mailing list