Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions pudb/debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,6 @@ class Debugger(bdb.Bdb):
def __init__(self, stdin=None, stdout=None, term_size=None, steal_output=False,
_continue_at_start=False, **kwargs):

if Debugger._current_debugger:
raise ValueError("a Debugger instance already exists")
Comment on lines -189 to -190
Copy link
Owner

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:

pudb/pudb/__init__.py

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]

Copy link
Author

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?

self._current_debugger.append(self)

# Pass remaining kwargs to python debugger framework
Expand Down