From 96dad7ea8069a697625a05f27859b308bd38563c Mon Sep 17 00:00:00 2001 From: Daniel Gerigk Date: Thu, 9 Sep 2021 22:04:37 +0200 Subject: [PATCH 1/3] Update pydevd_process_net_command_json.py - primarily, I changed the line `if self._options.django_debug:` to `if self._options.django_debug or self._options.flask_debug:`, so that if the debug option `"flask": true` is set, the debugger does not interrupt the program flow when the flask app is restarted due to a source file being changed. When a change in a source file is observed by the debugger, it causes a `SystemExit` exception with code `3`, and the reloader automatically restarts the flask app. - the other restructuring I did was due to my interpretation that even if `self._options.break_system_exit_zero` is `true`, i.e. if the debugger interrupts the flow when the program exits with error code `0`, the debugger still should not interrupt if it reloads the flask app due to a detected change in a source file. --- .../pydevd_process_net_command_json.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_process_net_command_json.py b/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_process_net_command_json.py index 6d50d568c..812bfafe0 100644 --- a/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_process_net_command_json.py +++ b/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_process_net_command_json.py @@ -395,13 +395,14 @@ def get_variable_presentation(setting, default): self.api.set_show_return_values(py_db, self._options.show_return_value) + ignore_system_exit_codes = [] if not self._options.break_system_exit_zero: - ignore_system_exit_codes = [0, None] - if self._options.django_debug: - ignore_system_exit_codes += [3] - - self.api.set_ignore_system_exit_codes(py_db, ignore_system_exit_codes) - + ignore_system_exit_codes += [0, None] + if self._options.django_debug or self._options.flask_debug: + ignore_system_exit_codes += [3] + if ignore_system_exit_codes != []: + self.api.set_ignore_system_exit_codes(py_db, ignore_system_exit_codes) + auto_reload = args.get('autoReload', {}) if not isinstance(auto_reload, dict): pydev_log.info('Expected autoReload to be a dict. Received: %s' % (auto_reload,)) From 76f7f4b0382899a3ad347d20469a037f450e45cd Mon Sep 17 00:00:00 2001 From: Daniel Gerigk Date: Wed, 15 Sep 2021 00:56:27 +0200 Subject: [PATCH 2/3] Restored the original version of the file, and only changed only line, to make the change as small as possible. --- .../pydevd_process_net_command_json.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_process_net_command_json.py b/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_process_net_command_json.py index 812bfafe0..4ffe5b204 100644 --- a/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_process_net_command_json.py +++ b/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_process_net_command_json.py @@ -394,15 +394,14 @@ def get_variable_presentation(setting, default): py_db.enable_output_redirection(False, False) self.api.set_show_return_values(py_db, self._options.show_return_value) - - ignore_system_exit_codes = [] + if not self._options.break_system_exit_zero: - ignore_system_exit_codes += [0, None] - if self._options.django_debug or self._options.flask_debug: - ignore_system_exit_codes += [3] - if ignore_system_exit_codes != []: - self.api.set_ignore_system_exit_codes(py_db, ignore_system_exit_codes) - + ignore_system_exit_codes = [0, None] + if self._options.django_debug or self._options.flask_debug: + ignore_system_exit_codes += [3] + + self.api.set_ignore_system_exit_codes(py_db, ignore_system_exit_codes) + auto_reload = args.get('autoReload', {}) if not isinstance(auto_reload, dict): pydev_log.info('Expected autoReload to be a dict. Received: %s' % (auto_reload,)) From a62fc31b8eac25b3efc115fcfa75025c3034104e Mon Sep 17 00:00:00 2001 From: Daniel Gerigk Date: Wed, 15 Sep 2021 00:57:20 +0200 Subject: [PATCH 3/3] Fixed formatting. --- .../pydevd/_pydevd_bundle/pydevd_process_net_command_json.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_process_net_command_json.py b/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_process_net_command_json.py index 4ffe5b204..9639e5ded 100644 --- a/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_process_net_command_json.py +++ b/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_process_net_command_json.py @@ -394,7 +394,7 @@ def get_variable_presentation(setting, default): py_db.enable_output_redirection(False, False) self.api.set_show_return_values(py_db, self._options.show_return_value) - + if not self._options.break_system_exit_zero: ignore_system_exit_codes = [0, None] if self._options.django_debug or self._options.flask_debug: