[issue5727] doctest pdb readline broken

Sriram report at bugs.python.org
Sun Dec 27 19:33:38 CET 2009

Sriram <sriramrathinavelu at yahoo.com> added the comment:


This is the first bug am working in python, kindly excuse my mistakes, 
if any.

As far as I can understand, the pdb disabled readline when an explicit 
stdin or stdout is passed, to allow remote debugging.

I found this in Python 2.5.4 Release log. 
Patch #721464: pdb.Pdb instances can now be given explicit stdin and
  stdout arguments, making it possible to redirect input and output
  for remote debugging.

Now in doctest.py since we pass the stdout argument (which is always 
sys.stdout) to pdb.py, readline is always disabled when pdb is invoked 
from doctest.py.

One fix I can think of is to have pdb disable use of readline, not if 
any output stream is passed but only if a output stream other than 
sys.stdout is passed. I infact believe, this will preserve the 
functionality of pdb.py that existed before release of version 2.5.4

The above fix would still not solve the problem because before we pass 
the output stream to pdb.py, we override sys.stdout in doctest to 
doctest's spoofout. So in pdb.py, sys.stdout will not point to real 
sys.stdout. This can be fixed by overriding sys.stdout after we 
initialize the debugger.

Please find the patch for doctest and pdb as an attachment. 


Added file: http://bugs.python.org/file15681/readline.patch

Python tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list