pdb and jump - newbie question

B

BiDi

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top