Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pudb/debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ def interaction(self, frame, exc_tuple=None, show_exc_dialog=True):
self.stack, index = self.get_shortened_stack(frame, tb)

if self.post_mortem:
self.stack.append((self.bottom_frame, self.bottom_frame.f_lineno))
Copy link
Copy Markdown
Owner

@inducer inducer Jul 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does pdb handle this situation? self.stack here is something that's managed by bdb, I'm not sure we're at liberty to modify it.

Copy link
Copy Markdown
Contributor Author

@qhuy4119 qhuy4119 Jul 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After finishing the execution of the script, pdb enters this finally block (kinda like our post-mortem mode). At this point, if we type p <variable name> on the command line, pdb will print a NameError, and the user continues with the pdb REPL. So currently our IndexError is similar to this NameError.

I haven't dig into how bdb manages the stack in this case.

The problem with the current PuDB is that if I have an object at the module level, say a = list(range(100)) for example, I can't expand it in post-mortem to see what the elements are . This PR allows user to inspect data structures like that.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of modifying data structures that aren't ours to modify, could you instead create a @property that provides a modified view of the stack, and then change the relevant spots of the code to use that view of the stack instead? Also make sure to add comments to explain why this is being done.

index = len(self.stack)-1

self.set_frame_index(index)
Expand Down