Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #3244

pdb and jump - newbie question

From BiDi <bidihall@gmail.com>
Newsgroups comp.lang.python
Subject pdb and jump - newbie question
Date 2011-04-14 22:01 -0700
Organization http://groups.google.com
Message-ID <1feea08a-531b-4ad5-90c5-1e8da9d33ee6@glegroupsg2000goo.googlegroups.com> (permalink)

Show all headers | View raw


I have been trying to figure out how to use pdb to correct simple errors in a file and then continue with program execution. Perhaps someone can tell me why this is not working for me.

Here is my file test.py:

#------------------
import pdb
pdb.set_trace()

print """
this is a test file
"""
x = 0
y = 4.2
z = y/x
print z

print "with a bug"
#------------------


The line `z = y/x` fails because x is zero.

If I run this, I can step until that exception occurs, at which point I see

ZeroDivisionError: 'float division'
> c:\temp\test.py(9)<module>()
-> z = y/x
(Pdb)

Now, I thought I would be able to set x to another value and then jump back to re-run the line with the division statement. However, that does not seem to work. Here's what happens:

(Pdb) !x = 2
(Pdb) j 9
> c:\temp\test.py(9)<module>()
-> z = y/x
(Pdb) n
--Return--
> c:\temp\test.py(9)<module>()->None
-> z = y/x
(Pdb) n
Traceback (most recent call last):
  File "C:\temp\test.py", line 9, in <module>
    z = y/x
ZeroDivisionError: float division

I have also tried assigning a value to z and jumping past the illegal division, but I can't get that to work either.

It seems that there must be a way to do this, but I can't find it. Any help would be appreciated.

 

Back to comp.lang.python | Previous | Next | Find similar


Thread

pdb and jump - newbie question BiDi <bidihall@gmail.com> - 2011-04-14 22:01 -0700

csiph-web