Questions tagged [pdb]

This tag refers to the Python debugger. For questions pertaining to the protein database file format, use the protein-database tag. For questions pertaining to Microsoft Program Database files, use the pdb-files tag.

The Python Debugger supports breakpoints, single stepping, inspection of stack frames, source code listing, and evaluation of arbitrary Python code in the context of any stack frame. It also supports post-mortem debugging and can be called under program control.

For questions pertaining to the protein database file format (.pdb), use the tag.

For questions pertaining to Microsoft "Program Database" (.pdb) files, use the tag.

880 questions
72
votes
5 answers

Attaching a process with pdb

I have a python script that I suspect that there is a deadlock. I was trying to debug with pdb but if I go step by step it doesn't get the deadlock, and by the output returned I can see that it's not being hanged on the same iteration. I would like…
62
votes
3 answers

PDB - stepping out of a function

Can I step out of a function after stepping into it with step while using pdb / ipdb debugger? And if there's no such option - what is the fastest way to get out of the stepped-in function?
Kludge
  • 2,653
  • 4
  • 20
  • 42
61
votes
4 answers

How do I list the current line in python PDB?

In the perl debugger, if you repeatedly list segments of code taking you away from the current line, you can return to the current line by entering the command . (dot). I have not been able to find anything comparable using the python PDB module.…
zenzic
  • 1,517
  • 2
  • 16
  • 25
61
votes
5 answers

Python debugger: Stepping into a function that you have called interactively

Python is quite cool, but unfortunately, its debugger is not as good as perl -d. One thing that I do very commonly when experimenting with code is to call a function from within the debugger, and step into that function, like so: # NOTE THAT THIS…
yga
60
votes
10 answers

BdbQuit raised when debugging Python with pdb

Recently when adding the pdb debugger to my Python 2.7.10 code, I get this message: Traceback (most recent call last): File "/Users/isaachess/Programming/vivint/Platform/MessageProcessing/vivint_cloud/queues/connectors/amqplib_connector.py", line…
isaachess
  • 739
  • 1
  • 7
  • 15
56
votes
3 answers

Debugging python programs in emacs

How do I debug python programs in emacs? I'm using python-mode.el I've found references suggesting: import pdb; pdb.set_trace(); but I'm not sure how to use it.
user90150
55
votes
3 answers

pdb.set_trace() causing frozen nosetests, does not drop into debugger

I'm running a suite of tests (.py files) using nosetests. Using a classic import pdb; pdb.set_trace() the nosetests run just never completes. It just hangs right where the breakpoint has been set, but never drops into the pdb debugger. Any ideas…
Bodhi
  • 1,437
  • 1
  • 13
  • 21
55
votes
9 answers

Python Unit Testing: Automatically Running the Debugger when a test fails

Is there a way to automatically start the debugger at the point at which a unittest fails? Right now I am just using pdb.set_trace() manually, but this is very tedious as I need to add it each time and take it out at the end. For Example: import…
tjb
  • 11,480
  • 9
  • 70
  • 91
53
votes
2 answers

How do you skip over a list comprehension in Python's debugger (pdb)?

In pdb the next instruction does not step over list comprehensions, instead it steps through each iteration. Is there a way to step over them so debugging will continue at the next line after the list comprehension? I've had to resort to listing the…
davidavr
  • 14,143
  • 4
  • 27
  • 31
51
votes
3 answers

Python debugger (pdb) stopped handlying up/down arrows, shows ^[[A instead

I am using python 2.6 in a virtualenv on an Ubuntu Linux 11.04 (natty) machine. I have this code in my (django) python code: import pdb ; pdb.set_trace() in order to launch the python debugger (pdb). Up until today, this worked fine. But now when…
Amandasaurus
  • 58,203
  • 71
  • 188
  • 248
49
votes
2 answers

How to set breakpoint in another module (don't set it on function definition line, if you want to break when function starts being executed)

I'm trying to debug a module "main", which calls a function "broken_function" at line 356 of "another_module". I'm having an error in that function and want to put a breakpoint at its start. Below is the listing. Am I doing something wrong? Cause,…
Boris Burkov
  • 13,420
  • 17
  • 74
  • 109
48
votes
1 answer

Python-pdb skip code (as in "not execute")

Is there a way to skip a line or two altogether in pdb? Say I have a pdb session: > print 10 import pdb; pdb.set_trace() destroy_the_universe() # side effect useful_line() And I want to go straight to useful_line() WITHOUT invoking pdb() once…
paroxyzm
  • 1,422
  • 2
  • 13
  • 29
46
votes
4 answers

How do I list all the attributes of an object in python pdb?

I try to list all the attributes of an object in Python pdb. Let's say I want to list all the attributes and all methods of sys.stderr. How can I do that?
sorin
  • 161,544
  • 178
  • 535
  • 806
45
votes
5 answers

In pdb how do you reset the list (l) command line count?

From PDB (Pdb) help l l(ist) [first [,last]] List source code for the current file. Without arguments, list 11 lines around the current line or continue the previous listing. With one argument, list 11 lines starting at that line. With two…
Jorge Vargas
  • 6,712
  • 7
  • 32
  • 29
43
votes
2 answers

Stepping into a function in IPython

Is there a way to step into the first line of a function in ipython. I imagine something that would look like: %step foo(1, 2) which runs ipdb and sets a breakpoint at the first line of foo. If I want to do this now I have to go to the function's…
Daniel
  • 26,899
  • 12
  • 60
  • 88
1
2
3
58 59