Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 416
Philipp F Avatar asked Aug 29 '19 08:08

Philipp F


People also ask

How do I enable debug mode in PyCharm?

Just right-click any line in the editor and select the Debug <filename> command from the context menu. After the program has been suspended, use the debugger to get the information about the state of the program and how it changes during running.

How do you Backtrace in PyCharm?

Press the Autoscroll to Trace toggle button on the toolbar. After that, on clicking a node in the Events pane, PyCharm shows its call stack in the Event Stack pane aqnd opens the corresponding trace file in the editor.

What does the lightning bolt mean in PyCharm?

button to resume the script execution. The exception is here. Another breakpoint appeared as well: by default PyCharm will halt for any exception that wasn't caught in your code, and it'll show an icon of a breakpoint with a lightning bolt. The debugger also shows the error message.


1 Answers

It works on PyCharm (Community) 2019.1.4:

Img0

Seems like you ran into a (regression) bug:

  • [JetBrains.YouTrack]: No Traceback in Debugger's Console
    • [JetBrains.YouTrack]: No stack trace is printed to the console when debugger breaks on exception

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)

@EDIT0

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

like image 98
CristiFati Avatar answered Sep 20 '22 14:09

CristiFati