Hi there,
When calling pdb.set_trace() from within a function, it seems to be impossible to rebind any local variables:
http://paste.pound-python.org/show/5150/
I couldn't find anything in the documentation about this, should I report a bug?
On Tue, Apr 12, 2011 at 11:15 AM, Djoume Salvetti dsalvetti@trapeze.com wrote: ..
When calling pdb.set_trace() from within a function, it seems to be impossible to rebind any local variables:
Works for me (using latest HG clone):
$ cat test.py gv = 1
def f(): lv = 1 import pdb; pdb.set_trace()
if __name__ == '__main__': f() $ ./python.exe test.py --Return--
/Users/sasha/Work/python-hg/py3k/test.py(5)f()->None
-> import pdb; pdb.set_trace() (Pdb) lv = 2 (Pdb) print lv 2
Please don't use paste services when posting on python-dev. Postings to this list are archived much longer than links to paste services remain valid.
I couldn't find anything in the documentation about this, should I report a bug?
If you find specific versions that are affected by this bug, please report it at bugs.python.org.
Thank you and sorry about the pastebin.
I can reproduce it on python 2.5.2 and python 2.6.6 but not on python 3.1.2 (all in ubuntu). I'll open a bug.
On 12/04/2011 18:01, Djoume Salvetti wrote:
Thank you and sorry about the pastebin.
I can reproduce it on python 2.5.2 and python 2.6.6 but not on python 3.1.2 (all in ubuntu). I'll open a bug.
Both Python 2.5 and 2.6 are in "security fix only" mode I'm afraid, so won't receive fixes for issues like this.
All the best,
Michael Foord
-- Djoume Salvetti Director of Development
T:416.601.1999 x 249 www.trapeze.com http://www.trapeze.com twitter: trapeze 175 Bloor St. E., South Tower, Suite 900 Toronto, ON M4W 3R8
Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/fuzzyman%40voidspace.org.u...
On Tue, Apr 12, 2011 at 10:01 AM, Djoume Salvetti dsalvetti@trapeze.com wrote:
Thank you and sorry about the pastebin. I can reproduce it on python 2.5.2 and python 2.6.6 but not on python 3.1.2 (all in ubuntu). I'll open a bug.
Looking at the pastebin you are using !lv = 2. Why the !? Without it, it works fine:
Python 2.5.5+ (release25-maint:86106, Dec 9 2010, 10:25:54) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information.
def f(x):
... import pdb; pdb.set_trace() ... return x ...
f(1)
<stdin>(3)f()
(Pdb) x 1 (Pdb) x = 2 (Pdb) c 2
On Tue, Apr 12, 2011 at 1:22 PM, Guido van Rossum guido@python.org wrote:
Looking at the pastebin you are using !lv = 2. Why the !? Without it, it works fine:
I just wanted to make sure I was executing a python statement and not a pdb alias. I re-tested without the exclamation mark and still have the same issue:
-> import pdb; pdb.set_trace() (Pdb) list 1 gv = 1 2 3 def f(): 4 lv = 1 5 -> import pdb; pdb.set_trace() 6 7 if __name__ == '__main__': 8 f() [EOF] (Pdb) lv 1 (Pdb) lv = 2 (Pdb) lv 1 (Pdb)
On Tue, Apr 12, 2011 at 11:01 AM, Djoume Salvetti dsalvetti@trapeze.com wrote:
On Tue, Apr 12, 2011 at 1:22 PM, Guido van Rossum guido@python.org wrote:
Looking at the pastebin you are using !lv = 2. Why the !? Without it, it works fine:
I just wanted to make sure I was executing a python statement and not a pdb alias. I re-tested without the exclamation mark and still have the same issue: -> import pdb; pdb.set_trace() (Pdb) list 1 gv = 1 2 3 def f(): 4 lv = 1 5 -> import pdb; pdb.set_trace() 6 7 if __name__ == '__main__': 8 f() [EOF] (Pdb) lv 1 (Pdb) lv = 2 (Pdb) lv 1 (Pdb)
Interesting. You'll find that if you let the function continue, lv is actually set to 2. Why pdb prints 1 I don't know. It might be interesting to find out why that is, although since it's fixed in Python 2.7 and Python 3, perhaps observing the changes in pdb.py (or other related code) between Python 2.6 and 2.7 might be the quickest way to find out.
On Tue, Apr 12, 2011 at 6:01 PM, Djoume Salvetti dsalvetti@trapeze.com wrote:
Thank you and sorry about the pastebin. I can reproduce it on python 2.5.2 and python 2.6.6 but not on python 3.1.2 (all in ubuntu). I'll open a bug.
Is http://bugs.python.org/issue5215 the same issue?
Mark
Hasn't it always been like that? I tried with Python 2.3 now and it's the same. I have no memory of that actually changing an existing variable in any version of Python I've used. More testing turns out that this works:
-> print "lv is ", lv (Pdb) lv=2 (Pdb) c lv is 2
While this seem to "reset" is:
-> print "lv is ", lv (Pdb) lv=2 (Pdb) lv 1 (Pdb) c lv is 1
This is the same from Python 2.3 to 2.6. I thought is just was a lack of feature, that there for some reason was really hard to change the value of an existing variable from the debugger. I though that for ten years. It never occurred to me to change the variable and type c without first checking that the variable had changed... :-)
It is however fixed in 2.7.
-> print "lv is ", lv (Pdb) lv=2 (Pdb) lv 2 (Pdb) c lv is 2
But this bug/lack of feature has been there as long as I can remember. :-)
//Lennart
On Tue, Apr 12, 2011 at 1:05 PM, Lennart Regebro regebro@gmail.com wrote:
Hasn't it always been like that? I tried with Python 2.3 now and it's the same. I have no memory of that actually changing an existing variable in any version of Python I've used. More testing turns out that this works:
-> print "lv is ", lv (Pdb) lv=2 (Pdb) c lv is 2
While this seem to "reset" is:
-> print "lv is ", lv (Pdb) lv=2 (Pdb) lv 1 (Pdb) c lv is 1
This is the same from Python 2.3 to 2.6. I thought is just was a lack of feature, that there for some reason was really hard to change the value of an existing variable from the debugger. I though that for ten years. It never occurred to me to change the variable and type c without first checking that the variable had changed... :-)
It is however fixed in 2.7.
-> print "lv is ", lv (Pdb) lv=2 (Pdb) lv 2 (Pdb) c lv is 2
But this bug/lack of feature has been there as long as I can remember. :-)
I swear it was my intention that assigning to locals would work, and I was surprised to learn that it didn't. I'm glad it's fixed in 2.7 though... :-)
On Tue, 12 Apr 2011 22:05:57 +0200, Lennart Regebro regebro@gmail.com wrote:
This is the same from Python 2.3 to 2.6. I thought is just was a lack of feature, that there for some reason was really hard to change the value of an existing variable from the debugger. I though that for ten years. It never occurred to me to change the variable and type c without first checking that the variable had changed... :-)
It is however fixed in 2.7.
For the curious:
http://bugs.python.org/issue5215
-- R. David Murray http://www.bitdance.com