The problem is that sys.stdin
is not attached to anything normally. But, sys.stdin
does work if you start SublimeText2 from a console:
On Mac, start the application by locating the executable in the resource bundle by entering the full path in the Terminal:
/Applications/Sublime\ Text\ 2.app/Contents/MacOS/Sublime\ Text\ 2
On Windows, start the application from the Windows Console:
"C:\Program Files\Sublime Text 2\sublime_text.exe"
provisional, I have no Windows Sublime Text 2 install so this command line is based on a quick Google
Now the application has a console; but sys.stdout
is still redirected to the built-in SublimeText 2 console. You want to start your debugger with the correct stdout
, the one still connected to your console. Instead of import pdb; pdb.set_trace()
, use:
import pdb, sys; pdb.Pdb(stdout=sys.__stdout__).set_trace()
The original console stdout
is saved in sys.__stdout__
and by passing that to pdb.Pdb()
you get a fully functional pdb
session.