gruns / icecream

🍦 Never use print() to debug again.
MIT License
9.22k stars 187 forks source link

Doesn't work while pdb is tracing #96

Open alexmojaki opened 3 years ago

alexmojaki commented 3 years ago

Example script:

from icecream import ic
breakpoint()
ic(len)
ic(sum)

Stepping through the lines with n, everything works fine:

$ python script.py
> script.py(3)<module>()
-> ic(len)
(Pdb) n
ic| len: <built-in function len>
> script.py(4)<module>()
-> ic(sum)
(Pdb) 
ic| sum: <built-in function sum>
--Return--
> script.py(4)<module>()->None
-> ic(sum)
(Pdb) c

But if I immediately continue with c, it fails on the second ic() call.

$ python script.py
> script.py(3)<module>()
-> ic(len)
(Pdb) c
ic| len: <built-in function len>
ic| Error: Failed to access the underlying source code for analysis. Was ic() invoked in a REPL (e.g. from the command line), a frozen application (e.g. packaged with PyInstaller), or did the underlying source code change during execution?