Skip to content

Fix set_trace(paused=False) #688

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

asmeurer
Copy link
Collaborator

@asmeurer asmeurer commented Jun 9, 2025

Previously this gave an exception like

>>> pudb._get_debugger().set_trace(paused=False)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/aaronmeurer/miniconda3/lib/python3.11/site-packages/pudb/debugger.py", line 291, in set_trace
    self.set_continue()
  File "/Users/aaronmeurer/miniconda3/lib/python3.11/bdb.py", line 344, in set_continue
    self._set_stopinfo(self.botframe, None, -1)
                       ^^^^^^^^^^^^^
AttributeError: 'Debugger' object has no attribute 'botframe'

The fix is to always set the botframe variable, even when paused=False, because after commit 2b08f08, the bdb set_continue method is used, which requires botframe to be set.

Previously this gave an exception like

>>> pudb._get_debugger().set_trace(paused=False)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/aaronmeurer/miniconda3/lib/python3.11/site-packages/pudb/debugger.py", line 291, in set_trace
    self.set_continue()
  File "/Users/aaronmeurer/miniconda3/lib/python3.11/bdb.py", line 344, in set_continue
    self._set_stopinfo(self.botframe, None, -1)
                       ^^^^^^^^^^^^^
AttributeError: 'Debugger' object has no attribute 'botframe'

The fix is to always set the botframe variable, even when paused=False,
because after commit 2b08f08, the bdb
set_continue method is used, which requires botframe to be set.
@@ -262,24 +262,22 @@ def set_trace(self, frame=None, as_breakpoint=None, paused=True):
# See pudb issue #52. If this works well enough we should upstream to
# stdlib bdb.py.
# self.reset()

if paused:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

FYI the only change here is removing this line (this is clearer if you look at https://github.com/inducer/pudb/pull/688/files?w=1)

@asmeurer
Copy link
Collaborator Author

asmeurer commented Jun 9, 2025

The type checker doesn't like these changes. How do I fix that? (it's kind of ironic; the type checker would have been useful if it had flagged these attributes as not being defined they way they were before, conditionally under the if paused block. But only now that they're defined unconditionally does it start to have problems)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant