diff --git a/python/helpers/pydev/pydevd.py b/python/helpers/pydev/pydevd.py index 913a6acb06ed..a9d9509f1e69 100644 --- a/python/helpers/pydev/pydevd.py +++ b/python/helpers/pydev/pydevd.py @@ -1189,6 +1189,13 @@ class PyDB(object): pydev_log.debug("We are stopping in post-mortem\n") thread_id = get_thread_id(thread) pydevd_vars.add_additional_frame_by_id(thread_id, frames_byid) + exctype, value, tb = arg + while tb: + if self.is_top_level_trace_in_project_scope(tb): + break + tb = tb.tb_next + sys.__excepthook__(exctype, value, tb) + sys.excepthook = lambda type, value, traceback: None # Avoid printing the exception for the second time. try: try: add_exception_to_frame(frame, arg) diff --git a/python/testSrc/com/jetbrains/env/python/PythonDebuggerTest.java b/python/testSrc/com/jetbrains/env/python/PythonDebuggerTest.java index 541834f05419..887494c7b59f 100644 --- a/python/testSrc/com/jetbrains/env/python/PythonDebuggerTest.java +++ b/python/testSrc/com/jetbrains/env/python/PythonDebuggerTest.java @@ -456,6 +456,10 @@ public class PythonDebuggerTest extends PyEnvTestCase { public void testing() throws Exception { waitForPause(); waitForOutput("message=\"python-exceptions.ZeroDivisionError\"", "message=\"python-builtins.ZeroDivisionError\""); + waitForOutput("Traceback (most recent call last):"); + waitForOutput("line 7, in foo"); + waitForOutput("return 1 / x"); + waitForOutput("ZeroDivisionError: "); eval("__exception__[0].__name__").hasValue("'ZeroDivisionError'"); resume(); waitForTerminate();