Debugger for wxPython and Linux?

Yeah, I read too fast...

"(all locals are fast locals except when a function uses exec or import *)" -- GvR on ActiveState Community - Boosting coder and team productivity with ready-to-use open source languages and tools.

From experimenting, looks like globals can be modified (cc, dd, and ee). Any other interesting twists?

import pdb
def main():
  a=1
  print a

pdb.set_trace()
main()
cc = 5
print cc
dd = {4:44, 5:55}
print dd
ee = [4,4]
print ee

Bruce

···

-----Original Message-----
From: Grzegorz Makarewicz [mailto:mak@trisoft.com.pl]
Sent: Monday, April 07, 2003 9:54 AM
To: wxPython-users@lists.wxwindows.org
Subject: Re: [wxPython-users] RE: Re: Debugger for wxPython and Linux?

brucedickey wrote:

Grzegorz (Mak),

Thanks for the education. Had only tried the case as for "self.b" below, which is the only case that works. I've now read ALL LOCALS are "fast locals" -- learned something there.

Which isn`t true too :slight_smile: - sometimes python creates locals on stack, but
sometimes not.

code='''
a=1
print a
'''
g={}
l=g
exec code in g,l

now play with warious combinations of g and l:
globals(), locals(), None and {}

then check Python/ceval.c exec_statement function

Happy hacking,
mak

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

brucedickey wrote:

Yeah, I read too fast...

"(all locals are fast locals except when a function uses exec or import *)" -- GvR on ActiveState Community - Boosting coder and team productivity with ready-to-use open source languages and tools.

From experimenting, looks like globals can be modified (cc, dd, and ee). Any other interesting twists?

Locals (even fast locals) can be modified too - with small trick at "C" level.

PyObject *func(PyObject *self, PyObject *args){

PyFrameObject *frame;
PyObject *key,*value;

     if( !PyArg_ParseTuple(args,"O!OO:f_set_in_locals",&PyFrame_Type,&frame,&key,&value))
         return NULL;
     PyFrame_FastToLocals(frame);
     if( PyDict_SetItem(frame->f_locals,key,value)!=0 ){
         PyErr_SetString( PyExc_IOError,"PyDict_SetItem failed");
         return NULL;
     }
     PyFrame_LocalsToFast(frame,0);
     Py_INCREF(Py_None);
     return Py_None;
}

Just create an extension module with this small function and modify pdb's default function (works with python >= 1.5.2) - but it's slooooow.

mak