Search code examples
pythondebuggingpycharm

PyCharm 2019.2 not showing Traceback on Exception


Very simple minimal example:

if __name__ == '__main__':
    print("Still ok")
    raise Exception("Dummy exception")
    print("End of Program")

I get this output when running it in the PyCharm 2019.2 debugger with Python 3.6:

/usr/bin/python3.6 /home/[...]/pycharm-community-2019.2/helpers/pydev/pydevd.py --multiproc --qt-support=auto --client 127.0.0.1 --port 46850 --file /home/[...]/test_traceback.py
pydev debugger: process 18394 is connecting

Connected to pydev debugger (build 192.5728.105)
Still ok

At this point the debugger breaks the execution flow but no Traceback and Exception message is shown in the Debugger console. If I run the same in PyCharm 2018.1 it does show these right when the breakpoint is hit.

When I hit Continue, I get the desired output, but then I can't run code in the debugging context anymore because the process ends:

Traceback (most recent call last):
  File "/home/[...]/pycharm-community-2019.2/helpers/pydev/pydevd.py", line 2060, in <module>
    main()
  File "/home/[...]/pycharm-community-2019.2/helpers/pydev/pydevd.py", line 2054, in main
    globals = debugger.run(setup['file'], None, None, is_module)
  File "/home/[...]/pycharm-community-2019.2/helpers/pydev/pydevd.py", line 1405, in run
    return self._exec(is_module, entry_point_fn, module_name, file, globals, locals)
  File "/home/[...]/pycharm-community-2019.2/helpers/pydev/pydevd.py", line 1412, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/home/[...]/pycharm-community-2019.2/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "/home/[...]/test_traceback.py", line 4, in <module>
    raise Exception("Dummy exception")
Exception: Dummy exception

Process finished with exit code 1

My Breakpoint configuration:

Breakpoint config


Solution

  • It works on PyCharm (Community) 2019.1.4:

    Img0

    Seems like you ran into a (regression) bug:

    which affects v2019.2.1, and is scheduled to be fixed in v2019.2.3.

    To get past this issue, you'll have to either:

    • Wait for v2019.2.3 (or any other that has the fix) to be released, and switch to that (might want to (periodically) check [JetBrains.Blog]: Release Announcements)

    • Revert to a (previous) version which is not affected by the bug (as I already mentioned: 2019.1.4)

    As a note: when running into this kinds of situations, in the (unlikely) case that the problem is not yet known, one could take matters into their own hands, do some debugging, and fix the problem (maybe submit a patch with the fix to JetBrains). Check [SO]: Run / Debug a Django application's UnitTests from the mouse right click context menu in PyCharm Community Edition? for an example.



    Update #0

    Installed (on 20190930) latest patch (v2019.2.3), and the traceback is present in PyCharm's console (so, the bug is fixed).