pudb icon indicating copy to clipboard operation
pudb copied to clipboard

Fix set_trace(paused=False)

Open asmeurer opened this issue 8 months ago • 1 comments

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 2b08f08910da00e58df736c719f11ae75bd5333c, the bdb set_continue method is used, which requires botframe to be set.

asmeurer avatar Jun 09 '25 17:06 asmeurer

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)

asmeurer avatar Jun 09 '25 17:06 asmeurer

@inducer do you know how to fix all the type checker warnings here? I'd like to get this merged.

asmeurer avatar Jul 22 '25 22:07 asmeurer

Well, this has sent me down quite the rabbit hole, including the discovery of a typeshed bug: https://github.com/python/typeshed/pull/14502. :slightly_smiling_face:

inducer avatar Jul 31 '25 19:07 inducer

Thanks!

inducer avatar Jul 31 '25 19:07 inducer

Wow I don't know if I could have figured all that out.

asmeurer avatar Aug 02 '25 17:08 asmeurer

Oh, not all of that was required, by any stretch. It's just that, somehow, adding types turns into an engaging video game if you have an LSP and see the warnings drop like flies... :)

inducer avatar Aug 02 '25 19:08 inducer

Any chance this could be put into a release?

asmeurer avatar Sep 23 '25 17:09 asmeurer

https://pypi.org/project/pudb/2025.1.1/

inducer avatar Sep 23 '25 18:09 inducer