pudb icon indicating copy to clipboard operation
pudb copied to clipboard

Make the Debugger a singleton and do not reset the stopframe to None during postmortem.

Open hwalinga opened this issue 1 year ago • 5 comments

This fixes #607. Making the Debugger a singleton should be enough to fix #607. HOWEVER, pytest def postmortem() calls .reset() which resets the stopframe. Somehow, this causes the debugger to stop somewhere inside internal debugger source code, instead of in the code the postmortem should be done.

So, this also includes an override of the .reset() method and detects when the debugger is already running and does not reset the stopframe. See also #67.

hwalinga avatar Nov 29 '24 18:11 hwalinga

Reproduce issue.

Install pytest and pudb.

test.py:

def test_foo():
    breakpoint()
    raise Exception
pytest --pdbcls pudb.debugger:Debugger --pdb --capture=no test.py

NB. The stopframe issue (#52) can also be observed with pytest-pudb using

pytest --pudb test.py

hwalinga avatar Nov 29 '24 19:11 hwalinga

@inducer Added more comments.

hwalinga avatar Dec 20 '24 12:12 hwalinga

Unsubscribing... @-mention or request review once it's ready for a look or needs attention.

inducer avatar Jan 16 '25 19:01 inducer

Does this affect recursive debugging? I know that's not something that we should always expect to work, but I think it is something that has worked at least in limited cases.

asmeurer avatar Jun 09 '25 17:06 asmeurer

@asmeurer What does recursive debugging mean here? Do you mean debugging a recursive function? That would not be affected.

hwalinga avatar Jun 10 '25 14:06 hwalinga