Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Python debugger

Reply
Thread Tools

Python debugger

 
 
Guillermo Fernandez
Guest
Posts: n/a
 
      10-16-2003
Hi,

I'm trying to play with the python debugger. The idea is to put lines in the
code to automatically define breakpoints at the starting of the debugger.

(like:

1 def a():
2 #--- break
3 print 'done'

would automatically insert a break in the line number 2)

I did the code appended (I'm still quite a beginner...) but it makes me problems.
Traceback (most recent call last):
File "C:\Python23\lib\site-packages\sm\scriptutils.py", line 52, in run
sdb.run('exec codeObject in mainDict', locals(), mainDict)
File "C:\Python23\lib\site-packages\sm\spedb.py", line 29, in run
Sdb().run(statement, globals, locals)
File "C:\Python23\lib\site-packages\sm\spedb.py", line 23, in run
pdb.Pdb.do_break(self, str(linenbr))
File "C:\Python23\lib\pdb.py", line 262, in do_break
filename = self.defaultFile()
File "C:\Python23\lib\pdb.py", line 278, in defaultFile
filename = self.curframe.f_code.co_filename
AttributeError: Sdb instance has no attribute 'curframe'
Exception raised while running script <source>

I run the program as:
import spedb
mainDict=__main__.__dict__
# mainDict can also be another argument passed,
# I think it's also locals() by default
mainDict['codeObject']=codeObject
spedb.run('exec codeObject in mainDict', locals(), mainDict)


I think it's because the breakpoint it's instaured before the run, but I really
don't know how to put the breakpoint "inside" the run.

Furthermore, if I define the method run like:
def run(self, statement, globals, locals):
bdb.Bdb.run(self, statement, globals, locals)
it does not even prompt the usual prompt (not any prompt at all...)!
I got this:
>>> Running 'C:\Python23\Lib\site-packages\sm\spedb.py' ...

Script '<source>' returned exit code 0

Could someone give me a hint about:
1) Why it does not work?
2) How to modify it the way I want?

Thanks a lot.

G

import pdb
import bdb

class Sdb(bdb.Bdb,pdb.Pdb):
def __init__(self):
pdb.Pdb.__init__(self)
bdb.Bdb.__init__(self)

def run(self, statement, globals, locals):
functions={
'#--- break' : pdb.Pdb.do_break
}
lines=globals['source'].splitlines()
linenbr=0
for line in lines:
linenbr+=1
if line in functions:
pdb.Pdb.do_break(self, str(linenbr))
bdb.Bdb.run(self, statement, globals, locals)

def run(statement, globals=None, locals=None):
Sdb().run(statement, globals, locals)


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Help getting a debugger going for IE - any free debugger aflat362 Javascript 7 12-07-2006 10:51 PM
Neither IE-Debugger or Mozilla/Venkman debugger can step through dynamically added code? Robert Oschler Javascript 1 09-05-2005 07:17 AM
Graphic python debugger Maxime Biais Python 5 09-18-2003 02:49 AM
Python Debugger Lothar Scholz Python 7 08-23-2003 04:34 PM
Python debugger Andrew Chalk Python 3 08-03-2003 03:06 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57