Make the Debugger a singleton and do not reset the stopframe to None during postmortem.
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.
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
@inducer Added more comments.
Unsubscribing... @-mention or request review once it's ready for a look or needs attention.
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 What does recursive debugging mean here? Do you mean debugging a recursive function? That would not be affected.