-
Notifications
You must be signed in to change notification settings - Fork 230
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
Do not raise when an instance already exists (fixes issue #607) #610
base: main
Are you sure you want to change the base?
Conversation
if Debugger._current_debugger: | ||
raise ValueError("a Debugger instance already exists") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with this is that various parts of the code assume that only one of these objects ever exists, e.g. here:
Lines 74 to 90 in b9c1948
def _get_debugger(**kwargs): | |
from pudb.debugger import Debugger | |
if not Debugger._current_debugger: | |
tty_path = _tty_override() | |
if tty_path and ("stdin" not in kwargs or "stdout" not in kwargs): | |
tty_file, term_size = _open_tty(tty_path) | |
kwargs.setdefault("stdin", tty_file) | |
kwargs.setdefault("stdout", tty_file) | |
kwargs.setdefault("term_size", term_size) | |
tty_file.close() | |
from pudb.debugger import Debugger | |
dbg = Debugger(**kwargs) | |
return dbg | |
else: | |
return Debugger._current_debugger[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see... can you think of way to fix the issue without messing with those parts of the code? Maybe we can destroy the pudb instance when c
is pressed?
This seems like the wrong fix. If the debugger is already running then further breakpoints should just break the debugger. If that doesn't happen we should try to investigate why. Having multiple debugger classes implies recursive debugging, which sounds really complicated and probably not worth supporting. |
@asmeurer Hello I did an analysis of this. If you use Making Debugger a singleton using metaclasses should solve this. HOWEVER, an old bug from #52 resurfaced then. I tried to fix this in #667 What is more, pytest-pudb also has exhibits the bug in #52 when using below code:
|
Do not raise when an instance already exists (fixes issue #607)
I assume that this is a dirty fix, yet it works for me.
Please let me know what is the good way to fix the issue, I would like to tackle it.
How to reproduce is described here.