I am trying to use the "pdb" python debugger (https://docs.python.org/3/library/pdb.html) in a Jupyter Notebook, but it is not behaving as expected.
In particular, when I run the following code
from pdb import set_trace
set_trace()
print("This is the next line")
for j in range(0,5):
print(j)
the debugger is entered as expected, displaying
--Return--
> <ipython-input-4-ed8fefd89436>(3)<module>()->None
-> set_trace()
with the (PBD) command line. However, when I type n into this command line, and hit "enter", attempting to move the debugger to the next line, something unexpected happens -- the output is updated to
--Return--
> <ipython-input-4-ed8fefd89436>(3)<module>()->None
-> set_trace()
(Pdb) n
> c:\python\lib\site-packages\ipython\core\interactiveshell.py(2913)run_code()
-> sys.excepthook = old_excepthook
Entering n a few more times gives
--Return--
> <ipython-input-4-ed8fefd89436>(3)<module>()->None
-> set_trace()
(Pdb) n
> c:\python\lib\site-packages\ipython\core\interactiveshell.py(2913)run_code()
-> sys.excepthook = old_excepthook
(Pdb) n
> c:\python\lib\site-packages\ipython\core\interactiveshell.py(2929)run_code()
-> outflag = False
(Pdb) n
> c:\python\lib\site-packages\ipython\core\interactiveshell.py(2930)run_code()
-> return outflag
(Pdb) n
--Return--
> c:\python\lib\site-packages\ipython\core\interactiveshell.py(2930)run_code()->False
-> return outflag
(Pdb) n
> c:\python\lib\site-packages\ipython\core\interactiveshell.py(2847)run_ast_nodes()
-> for i, node in enumerate(to_run_exec):
What's going on here? The code the debugger is stepping through is not mine...