Skip to content

Commit b5f0dae

Browse files
committed
Use stack property to return a modified view of the stack in post_mortem
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.
1 parent 99a32b6 commit b5f0dae

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

pudb/debugger.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,14 @@ def __init__(self, stdin=None, stdout=None, term_size=None, steal_output=False,
200200
for bpoint_descr in load_breakpoints():
201201
self.set_break(*bpoint_descr)
202202

203+
@property
204+
def stack(self):
205+
if self.post_mortem:
206+
# Return the bottom frame so the user can expand variables in post_mortem
207+
return [(self.bottom_frame, self.bottom_frame.f_lineno)]
208+
else:
209+
return self._stack
210+
203211
# These (dispatch_line and set_continue) are copied from bdb with the
204212
# patch from https://bugs.python.org/issue16482 applied. See
205213
# https://github.com/inducer/pudb/pull/90.
@@ -401,10 +409,9 @@ def interaction(self, frame, exc_tuple=None, show_exc_dialog=True):
401409
if not found_bottom_frame and not self.post_mortem:
402410
return
403411

404-
self.stack, index = self.get_shortened_stack(frame, tb)
412+
self._stack, index = self.get_shortened_stack(frame, tb)
405413

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

410417
self.set_frame_index(index)

0 commit comments

Comments
 (0)