diff --git a/src/ptvsd/_vendored/pydevd/_pydevd_frame_eval/pydevd_frame_tracing.py b/src/ptvsd/_vendored/pydevd/_pydevd_frame_eval/pydevd_frame_tracing.py index f76fff0ef..0968b048e 100644 --- a/src/ptvsd/_vendored/pydevd/_pydevd_frame_eval/pydevd_frame_tracing.py +++ b/src/ptvsd/_vendored/pydevd/_pydevd_frame_eval/pydevd_frame_tracing.py @@ -46,12 +46,15 @@ def _pydev_stop_at_break(line): abs_path_real_path_and_base = get_abs_path_real_path_and_base_from_frame(frame) filename = abs_path_real_path_and_base[1] - breakpoints_for_file = debugger.breakpoints.get(filename) - try: - python_breakpoint = breakpoints_for_file[line] - except KeyError: - pydev_log.debug("Couldn't find breakpoint in the file {} on line {}".format(frame.f_code.co_filename, line)) + python_breakpoint = debugger.breakpoints[filename][line] + except: + # print("Couldn't find breakpoint in the file %s on line %s" % (frame.f_code.co_filename, line)) + # Could be KeyError if line is not there or TypeError if breakpoints_for_file is None. + # Note: using catch-all exception for performance reasons (if the user adds a breakpoint + # and then removes it after hitting it once, this method added for the programmatic + # breakpoint will keep on being called and one of those exceptions will always be raised + # here). return if python_breakpoint: diff --git a/src/ptvsd/_vendored/pydevd/tests_python/test_debugger_json.py b/src/ptvsd/_vendored/pydevd/tests_python/test_debugger_json.py index f71829f21..b3d80d77a 100644 --- a/src/ptvsd/_vendored/pydevd/tests_python/test_debugger_json.py +++ b/src/ptvsd/_vendored/pydevd/tests_python/test_debugger_json.py @@ -50,7 +50,7 @@ def write_make_initial_run(self): def write_list_threads(self): return self.wait_for_response(self.write_request(pydevd_schema.ThreadsRequest())) - def write_add_breakpoints(self, lines, filename=None, line_to_info=None): + def write_set_breakpoints(self, lines, filename=None, line_to_info=None): ''' Adds a breakpoint. ''' @@ -102,6 +102,27 @@ def write_disconnect(self): self.wait_for_response(self.write_request(request)) +@pytest.mark.skipif(IS_JYTHON, reason='Must check why it is failing in Jython.') +def test_case_json_change_breaks(case_setup): + with case_setup.test_file('_debugger_case_change_breaks.py') as writer: + json_facade = JsonFacade(writer) + + writer.write_set_protocol('http_json') + json_facade.write_launch() + json_facade.write_set_breakpoints(writer.get_line_index_with_content('break 1')) + json_facade.write_make_initial_run() + hit = writer.wait_for_breakpoint_hit() + writer.write_run_thread(hit.thread_id) + + hit = writer.wait_for_breakpoint_hit() + writer.write_run_thread(hit.thread_id) + + json_facade.write_set_breakpoints([]) + writer.write_run_thread(hit.thread_id) + + writer.finished_ok = True + + @pytest.mark.skipif(IS_JYTHON, reason='Must check why it is failing in Jython.') def test_case_json_protocol(case_setup): with case_setup.test_file('_debugger_case_print.py') as writer: @@ -109,7 +130,7 @@ def test_case_json_protocol(case_setup): writer.write_set_protocol('http_json') json_facade.write_launch() - json_facade.write_add_breakpoints(writer.get_line_index_with_content('Break here')) + json_facade.write_set_breakpoints(writer.get_line_index_with_content('Break here')) json_facade.write_make_initial_run() json_facade.wait_for_json_message(ThreadEvent, lambda event: event.body.reason == 'started')