Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

pdb doesn't play nice with doctests.. this is a quick hack to fix that.

Project Description

What does it do? Fixes line numbers so you can easily figure out where your doctest is failing, also fixes
the list command in pdb so it can properly list the source code for your doctest.

Other things may be broken so please send feedback.

add to your $HOME/.pdbrc:

import doctestpdbhacks

Here's an example of what it does:

$ cat
def foo(a):
>>> foo(1)
>>> import pdb; pdb.set_trace()
>>> foo(2)
return a + 1

def _test():
import doctest

if __name__ == "__main__":

# without doctestpdbhacks

$ python
> <doctest[1]>(1)?()->None
-> import pdb; pdb.set_trace()
(Pdb) l
1 -> import pdb; pdb.set_trace()

# Turn on doctestpdbhacks:

$ echo >>$HOME/.pdbrc "import doctestpdbhacks"
$ python
> doctest @>None
-> >>> import pdb; pdb.set_trace()
(Pdb) l
1 def foo(a):
2 """
3 >>> foo(1)
4 2
5 -> >>> import pdb; pdb.set_trace()
6 >>> foo(2)
7 2
8 """
9 return a + 1
11 def _test():

Release History

This version
History Node


Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
(3.8 kB) Copy SHA256 Hash SHA256
Egg 2.4 Sep 26, 2008
(2.1 kB) Copy SHA256 Hash SHA256
Source None Sep 26, 2008

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Google Google Cloud Servers