mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-37120 Python debugger - properly stop on syntax errors
GitOrigin-RevId: e6280732fc658ed22741ac3cc5ba2535b4979e05
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d52a90d126
commit
6c8c1beb19
@@ -705,9 +705,15 @@ class NetCommandFactory:
|
||||
|
||||
abs_path_real_path_and_base = get_abs_path_real_path_and_base_from_frame(curr_frame)
|
||||
if get_file_type(abs_path_real_path_and_base[2]) == PYDEV_FILE:
|
||||
# Skip pydevd files.
|
||||
curr_frame = curr_frame.f_back
|
||||
continue
|
||||
# Syntax errors are a special case in which we don't want to skip the debugger files.
|
||||
# When a syntax error happens, we stop either in the `execfile` or `_exec` function.
|
||||
exception_info, is_syntax_error = curr_frame.f_locals.get('__exception__'), False
|
||||
if exception_info:
|
||||
is_syntax_error = exception_info[0] is SyntaxError
|
||||
if not is_syntax_error:
|
||||
# Skip pydevd files.
|
||||
curr_frame = curr_frame.f_back
|
||||
continue
|
||||
|
||||
my_file = abs_path_real_path_and_base[0]
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
x x
|
||||
@@ -488,6 +488,11 @@ public class PythonDebuggerTest extends PyEnvTestCase {
|
||||
addExceptionBreakpoint(fixture, properties);
|
||||
}
|
||||
|
||||
private static void createDefaultExceptionBreakpoint(IdeaProjectTestFixture fixture) {
|
||||
XDebuggerTestUtil.removeAllBreakpoints(fixture.getProject());
|
||||
XDebuggerTestUtil.setDefaultBreakpointEnabled(fixture.getProject(), PyExceptionBreakpointType.class, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExceptionBreakpointOnFirstRaise() {
|
||||
runPythonTest(new PyDebuggerTask("/debug", "test_exceptbreak.py") {
|
||||
@@ -2192,4 +2197,26 @@ public class PythonDebuggerTest extends PyEnvTestCase {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStopsOnSyntaxError() {
|
||||
runPythonTest(new PyDebuggerTask("/debug", "test_syntax_error.py") {
|
||||
@Override
|
||||
public void before() {
|
||||
createDefaultExceptionBreakpoint(myFixture);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testing() throws Exception {
|
||||
waitForPause();
|
||||
try {
|
||||
resume();
|
||||
waitForTerminate();
|
||||
}
|
||||
catch (AssertionError e) {
|
||||
if (!e.getMessage().contains("SyntaxError: invalid syntax")) throw e;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user