Skip to content

Commit

Permalink
Use stack property to return a modified view of the stack in post_mortem
Browse files Browse the repository at this point in the history
If we're in post_mortem, accessing the stack will return the bottom
frame instead of an empty stack. By doing this, users can expand
variables in post_mortem.
  • Loading branch information
qhuy4119 committed Jul 18, 2021
1 parent 99a32b6 commit 6b2c28a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pudb/debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,14 @@ def __init__(self, stdin=None, stdout=None, term_size=None, steal_output=False,
for bpoint_descr in load_breakpoints():
self.set_break(*bpoint_descr)

@property
def stack(self):
if self.post_mortem:
# Return the bottom frame so the user can expand variables in post_mortem
return [(self.bottom_frame, self.bottom_frame.f_lineno)]
else:
return self._stack

# These (dispatch_line and set_continue) are copied from bdb with the
# patch from https://bugs.python.org/issue16482 applied. See
# https://github.com/inducer/pudb/pull/90.
Expand Down Expand Up @@ -401,17 +409,17 @@ def interaction(self, frame, exc_tuple=None, show_exc_dialog=True):
if not found_bottom_frame and not self.post_mortem:
return

self.stack, index = self.get_shortened_stack(frame, tb)
self._stack, index = self.get_shortened_stack(frame, tb)

if self.post_mortem:
self.stack.append((self.bottom_frame, self.bottom_frame.f_lineno))
index = len(self.stack)-1

self.set_frame_index(index)

self.ui.call_with_ui(self.ui.interaction, exc_tuple,
show_exc_dialog=show_exc_dialog)


def get_stack_situation_id(self):
return str(id(self.stack[self.curindex][0].f_code))

Expand Down

0 comments on commit 6b2c28a

Please sign in to comment.