Fixed bug when debugging and encountering an exception
Permit replaying code prior to exception
@@ -934,8 +934,8 @@ class FancyTracer(Executor):
self._unhandled_exception = exc
if self._is_interesting_exception(frame):
- self._save_debugger_progress_message(frame , None)
- self._send_and_fetch_next_debugger_progress_message(self._past_messages[-1][0])
+ self._save_debugger_progress_message(frame)
+ self._handle_message_selection()
# TODO: support line event in non-instrumented files
elif event == "line":
@@ -1009,14 +1009,14 @@ class FancyTracer(Executor):
args = current_frame.last_event_args
focus = current_frame.last_event_focus
cmd = self._current_command
+ exc = self._past_messages[self._current_state][0]["exception"]
# Has the command completed?
tester = getattr(self, "_cmd_" + cmd.command + "_completed")
cmd_complete = tester(frame, event, args, focus, cmd)
-
- if cmd_complete:
- # Last command has completed, send message and fetch the next command
+ if cmd_complete or exc is not None:
+ # Last command has completed or a state caused an exception, send message and fetch the next command
self._past_messages[self._current_state][1] = True # Add "shown to user" flag
self._send_and_fetch_next_debugger_progress_message(self._past_messages[self._current_state][0])
@@ -1025,8 +1025,10 @@ class FancyTracer(Executor):
if self._current_state > 0: # Don't let the pointer have negative values
self._past_messages[self._current_state][1] = False # Remove "shown to user" flag
self._current_state -= 1
- else:
- # Other progress events move the pointer forward
+ elif exc is None or self._current_state != len(self._past_messages) - 1:
+ # Other progress events move the pointer forward,
+ # unless we are displaying the last state and an exception occurred
+ self._debug("Exception", exc)
self._current_state += 1
# Saved messages are no longer enough, let Python run to the next progress event
