From 63dfa204457ea9ff314f051b547a837617b59175 2012-11-06 23:43:07 From: Bradley M. Froehle Date: 2012-11-06 23:43:07 Subject: [PATCH] Avoid stopping in ipdb until we reach the main script. For example:: In [1]: %run -d -b 52 setup.py Breakpoint 1 at /tmp/ipython/setup.py:52 NOTE: Enter 'c' at the ipdb> prompt to start your script. > /tmp/ipython/setup.py(7)() 6 Under Windows, the command sdist is not supported, since IPython ----> 7 requires utilities which are not available under Windows.""" 8 compared to the previous behavior:: In [1]: %run -d -b 52 setup.py Breakpoint 1 at /tmp/ipython/setup.py:52 NOTE: Enter 'c' at the ipdb> prompt to start your script. > (1)() Closes #1679 ("List command desn't work in ipdb debugger the first time") --- diff --git a/IPython/core/magics/execution.py b/IPython/core/magics/execution.py index 3669ef2..1b916b7 100644 --- a/IPython/core/magics/execution.py +++ b/IPython/core/magics/execution.py @@ -563,6 +563,11 @@ python-profiler package from non-free.""") return # if we find a good linenumber, set the breakpoint deb.do_break('%s:%s' % (filename, bp)) + + # Mimic Pdb._runscript(...) + deb._wait_for_mainpyfile = True + deb.mainpyfile = deb.canonic(filename) + # Start file run print "NOTE: Enter 'c' at the", print "%s prompt to start your script." % deb.prompt