diff --git a/python/helpers/pydev/pydevd_frame.py b/python/helpers/pydev/pydevd_frame.py index c2e2f6caac98..e5a942c75775 100644 --- a/python/helpers/pydev/pydevd_frame.py +++ b/python/helpers/pydev/pydevd_frame.py @@ -78,6 +78,7 @@ class PyDBFrame: # print frame.f_code.co_name if exception_breakpoint.ignore_libraries: if mainDebugger.not_in_scope(frame.f_code.co_filename): + pydev_log.debug("Ignore exception %s in library %s" % (exception, frame.f_code.co_filename)) return False, frame add_exception_to_frame(frame, (exception, value, trace)) diff --git a/python/testData/debug/test_ignore_lib.py b/python/testData/debug/test_ignore_lib.py new file mode 100644 index 000000000000..b943636ba100 --- /dev/null +++ b/python/testData/debug/test_ignore_lib.py @@ -0,0 +1,3 @@ +from calendar import setfirstweekday +stopped_in_user_file = True +setfirstweekday(15) \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/env/python/PythonDebuggerTest.java b/python/testSrc/com/jetbrains/env/python/PythonDebuggerTest.java index d98f64957441..c80d7216a55a 100644 --- a/python/testSrc/com/jetbrains/env/python/PythonDebuggerTest.java +++ b/python/testSrc/com/jetbrains/env/python/PythonDebuggerTest.java @@ -324,7 +324,7 @@ public class PythonDebuggerTest extends PyEnvTestCase { runPythonTest(new PyDebuggerTask("/debug", "test_exceptbreak.py") { @Override public void before() throws Exception { - createExceptionBreak(myFixture, true, false, false); + createExceptionBreakZeroDivisionError(myFixture, true, false, false, false); } @Override @@ -342,10 +342,11 @@ public class PythonDebuggerTest extends PyEnvTestCase { }); } - private static void createExceptionBreak(IdeaProjectTestFixture fixture, - boolean notifyOnTerminate, - boolean notifyAlways, - boolean notifyOnFirst) { + private static void createExceptionBreakZeroDivisionError(IdeaProjectTestFixture fixture, + boolean notifyOnTerminate, + boolean notifyAlways, + boolean notifyOnFirst, + boolean ignoreLibraries) { XDebuggerTestUtil.removeAllBreakpoints(fixture.getProject()); XDebuggerTestUtil.setDefaultBreakpointEnabled(fixture.getProject(), PyExceptionBreakpointType.class, false); @@ -353,11 +354,13 @@ public class PythonDebuggerTest extends PyEnvTestCase { properties.setNotifyOnTerminate(notifyOnTerminate); properties.setNotifyAlways(notifyAlways); properties.setNotifyOnlyOnFirst(notifyOnFirst); + properties.setIgnoreLibraries(ignoreLibraries); addExceptionBreakpoint(fixture, properties); properties = new PyExceptionBreakpointProperties("builtins.ZeroDivisionError"); //for python 3 properties.setNotifyOnTerminate(notifyOnTerminate); properties.setNotifyAlways(notifyAlways); properties.setNotifyOnlyOnFirst(notifyOnFirst); + properties.setIgnoreLibraries(ignoreLibraries); addExceptionBreakpoint(fixture, properties); } @@ -365,7 +368,7 @@ public class PythonDebuggerTest extends PyEnvTestCase { runPythonTest(new PyDebuggerTask("/debug", "test_exceptbreak.py") { @Override public void before() throws Exception { - createExceptionBreak(myFixture, false, true, false); + createExceptionBreakZeroDivisionError(myFixture, false, true, false, false); } @Override @@ -391,7 +394,7 @@ public class PythonDebuggerTest extends PyEnvTestCase { runPythonTest(new PyDebuggerTask("/debug", "test_exceptbreak.py") { @Override public void before() throws Exception { - createExceptionBreak(myFixture, false, false, true); + createExceptionBreakZeroDivisionError(myFixture, false, false, true, false); } @Override @@ -409,6 +412,44 @@ public class PythonDebuggerTest extends PyEnvTestCase { }); } + private static void createExceptionBreak(IdeaProjectTestFixture fixture, + boolean notifyOnTerminate, + boolean notifyAlways, + boolean notifyOnFirst, + boolean ignoreLibraries) { + XDebuggerTestUtil.removeAllBreakpoints(fixture.getProject()); + XDebuggerTestUtil.setDefaultBreakpointEnabled(fixture.getProject(), PyExceptionBreakpointType.class, false); + + PyExceptionBreakpointProperties properties = new PyExceptionBreakpointProperties("BaseException"); + properties.setNotifyOnTerminate(notifyOnTerminate); + properties.setNotifyAlways(notifyAlways); + properties.setNotifyOnlyOnFirst(notifyOnFirst); + properties.setIgnoreLibraries(ignoreLibraries); + addExceptionBreakpoint(fixture, properties); + } + + public void testExceptionBreakpointIgnoreLibraries() throws Exception { + runPythonTest(new PyDebuggerTask("/debug", "test_ignore_lib.py") { + @Override + public void before() throws Exception { + createExceptionBreak(myFixture, false, true, false, true); + } + + @Override + public void testing() throws Exception { + waitForPause(); + eval("stopped_in_user_file").hasValue("True"); + resume(); + waitForTerminate(); + } + + @Override + public Set getTags() { + return ImmutableSet.of("-jython"); + } + }); + } + public void testMultithreading() throws Exception { runPythonTest(new PyDebuggerTask("/debug", "test_multithread.py") { @Override