Reputation: 13655
I'm trying to debug a Python program and I inserted a classic 'import pdb;pdb.set_trace()' line in a function, just before a call which generates a stack trace. However that call seems to be ignored, i.e. nothing happens and I don't get a pdb prompt.
At that point of the program, there is only one active thread. No monkey patching of the pdb module was detected.
Any help on what could cause the call to set_trace to be ignored is welcome. Thanks.
Platform info: Debian squeeze + python 2.6.5
Code extract:
import threading
print threading.active_count()
import pdb
print pdb
pdb.set_trace()
print "*****"
root_resource.init_publisher() # before changing uid
output:
<lots of stuff>
1
<module 'pdb' from '/usr/lib/python2.6/pdb.pyc'>
*****
<stack trace in init_publisher>
Upvotes: 13
Views: 14123
Reputation: 1993
This is going to waste the time of a number Python developers. Tonight I added myself to their ranks. I wish I had found this post before I spent 2 hours discovering a similar problem with a large library I am using. Subsequent Google searches hardly shed much light on the issue of pdb and pysco incompatability. The problem should be more visible to users starting out with pdb.
Deep within the guts of a library I was importing was a file which contained the following code:
try:
import psyco
psyco.bind(bdecode)
psyco.bind(bencode)
except ImportError:
pass
What a lovely gesture of the author, who obviously assumed no one using their code, and who had also installed psyco, would ever like to use a tool such as pdb to debug it ;-) Mind you, you could ask how were they mean't to know anyway?
Whilst exploring the problem I found that usage of:
import pdb; pdb.set_trace()
after the import of psyco, is just passed over; for neither rythme nor reason. Very frustrating indeed.
The problem does not effect debugging with PyDev or, I presume, other more advanced debuggers, which is I guess why it falls outside the radar of initial Google searches.
Upvotes: 5
Reputation: 376052
Perhaps you've got some tricky code that manipulates the trace function in a complicated way? Or are you using an accelerator like psyco?
Upvotes: 7
Reputation: 63792
You are probably not running that statement, either because:
Upvotes: 1