From 7053e2d0a2d6ee676f72f6c251e22db6f8a86a8b Mon Sep 17 00:00:00 2001 From: Elizaveta Shashkova Date: Wed, 24 Oct 2018 14:47:34 +0300 Subject: [PATCH] PY-32371 Fix stop after rerun with Console enabled --- .../_pydevd_bundle/pydevd_breakpointhook.py | 21 +++---------------- python/helpers/pydev/pydevd.py | 17 ++++++++++++++- .../pydev/pydevd_plugins/django_debug.py | 2 +- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/python/helpers/pydev/_pydevd_bundle/pydevd_breakpointhook.py b/python/helpers/pydev/_pydevd_bundle/pydevd_breakpointhook.py index 09e6a40d0db0..63055d6f5923 100644 --- a/python/helpers/pydev/_pydevd_bundle/pydevd_breakpointhook.py +++ b/python/helpers/pydev/_pydevd_bundle/pydevd_breakpointhook.py @@ -7,7 +7,7 @@ import os def breakpointhook(*args, **kwargs): # It's necessary to use inner function to add extra frame - def breakpoint(): + def pydevd_breakpointhook(): hookname = os.getenv('PYTHONBREAKPOINT') if hookname is not None and len(hookname) > 0 and hasattr(sys, '__breakpointhook__'): sys.__breakpointhook__(*args, **kwargs) @@ -22,21 +22,6 @@ def breakpointhook(*args, **kwargs): suspend=True, trace_only_current_thread=True, patch_multiprocessing=False, - stop_at_frame=sys._getframe(), + stop_at_frame=sys._getframe().f_back, ) - breakpoint() - - -def install_breakpointhook(pydevd_breakpointhook=None): - if pydevd_breakpointhook is None: - pydevd_breakpointhook = breakpointhook - if sys.version_info[0:2] >= (3, 7): - # There are some choices on how to provide the breakpoint hook. Namely, we can provide a - # PYTHONBREAKPOINT which provides the import path for a method to be executed or we - # can override sys.breakpointhook. - # pydevd overrides sys.breakpointhook instead of providing an environment variable because - # it's possible that the debugger starts the user program but is not available in the - # PYTHONPATH (and would thus fail to be imported if PYTHONBREAKPOINT was set to pydevd.settrace). - # Note that the implementation still takes PYTHONBREAKPOINT in account (so, if it was provided - # by someone else, it'd still work). - sys.breakpointhook = pydevd_breakpointhook + pydevd_breakpointhook() diff --git a/python/helpers/pydev/pydevd.py b/python/helpers/pydev/pydevd.py index ead311b037d4..fc3c1a45f888 100644 --- a/python/helpers/pydev/pydevd.py +++ b/python/helpers/pydev/pydevd.py @@ -34,7 +34,6 @@ from _pydevd_bundle.pydevd_comm import CMD_SET_BREAK, CMD_SET_NEXT_STATEMENT, CM set_global_debugger, WriterThread, pydevd_find_thread_by_id, pydevd_log, \ start_client, start_server, InternalGetBreakpointException, InternalSendCurrExceptionTrace, \ InternalSendCurrExceptionTraceProceeded -from _pydevd_bundle.pydevd_breakpointhook import install_breakpointhook from _pydevd_bundle.pydevd_custom_frames import CustomFramesContainer, custom_frames_container_init from _pydevd_bundle.pydevd_frame_utils import add_exception_to_frame from _pydevd_bundle.pydevd_kill_all_pydevd_threads import kill_all_pydev_threads @@ -56,6 +55,22 @@ __version__ = '.'.join(__version_info_str__) #IMPORTANT: pydevd_constants must be the 1st thing defined because it'll keep a reference to the original sys._getframe + +def install_breakpointhook(pydevd_breakpointhook=None): + if pydevd_breakpointhook is None: + from _pydevd_bundle.pydevd_breakpointhook import breakpointhook + pydevd_breakpointhook = breakpointhook + if sys.version_info[0:2] >= (3, 7): + # There are some choices on how to provide the breakpoint hook. Namely, we can provide a + # PYTHONBREAKPOINT which provides the import path for a method to be executed or we + # can override sys.breakpointhook. + # pydevd overrides sys.breakpointhook instead of providing an environment variable because + # it's possible that the debugger starts the user program but is not available in the + # PYTHONPATH (and would thus fail to be imported if PYTHONBREAKPOINT was set to pydevd.settrace). + # Note that the implementation still takes PYTHONBREAKPOINT in account (so, if it was provided + # by someone else, it'd still work). + sys.breakpointhook = pydevd_breakpointhook + # Install the breakpoint hook at import time. install_breakpointhook() diff --git a/python/helpers/pydev/pydevd_plugins/django_debug.py b/python/helpers/pydev/pydevd_plugins/django_debug.py index 0df8fc639556..8f1ea89a64ff 100644 --- a/python/helpers/pydev/pydevd_plugins/django_debug.py +++ b/python/helpers/pydev/pydevd_plugins/django_debug.py @@ -376,7 +376,7 @@ def cmd_step_over(plugin, main_debugger, frame, event, args, stop_info, stop): info.pydev_step_stop = frame.f_back info.pydev_django_resolve_frame = False thread.additional_info.suspend_type = DJANGO_SUSPEND - stop = info.pydev_step_stop is frame and event in ('line', 'return') + stop = info.pydev_step_stop is frame and event in ('line', 'return') return stop, plugin_stop