-
-
Notifications
You must be signed in to change notification settings - Fork 31.2k
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
gh-124703: Change back to raising bdb.BdbQuit when exiting pdb in 'inline' mode in a REPL session #130395
base: main
Are you sure you want to change the base?
Conversation
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
@@ -1758,7 +1758,8 @@ def do_quit(self, arg): | |||
Quit from the debugger. The program being executed is aborted. | |||
""" | |||
if self.mode == 'inline': | |||
in_repl_session = hasattr(sys, 'ps1') |
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 understand that you do not want a magic hasattr(sys, 'ps1')
here, but I think it's better to add some comments here about why we do it, instead of trying to use a variable with some explanation. This variable is only used once, in the next immediate line, and it's not even shorter than the actual statement.
@support.requires_subprocess() | ||
class TestREPLSession(unittest.TestCase): | ||
def test_return_from_inline_mode_to_REPL(self): | ||
# Issue #124703: Raise BdbQuit when exiting pdb in REPL session. |
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.
# Issue #124703: Raise BdbQuit when exiting pdb in REPL session. | |
# GH-124703: Raise BdbQuit when exiting pdb in REPL session. |
pdb.set_trace(commands=['x * 3', 'q']) | ||
print('Afterward') | ||
""" | ||
p = spawn_repl() |
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.
Can we import the spawn_repl
from test_repl
here? So we don't need to keep a copy.
@@ -0,0 +1 @@ | |||
Restore the ability to easily return to the REPL from a pdb session after calling ``breakpoint`` or ``set_trace``. |
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.
Restore the ability to easily return to the REPL from a pdb session after calling ``breakpoint`` or ``set_trace``. | |
Executing ``quit`` command in :mod:`pdb` will raise :exc:`bdb.BdbQuit` when :mod:`pdb` is started from an interactive console using :func:`breakpoint` or :func:`pdb.set_trace`. |
This change should mean it's again possible to call breakpoint() in a REPL session and return to the REPL session with q/quit/exit/EOF.
The test has a slight workaround/hack because I couldn't figure out how to call breakpoint() and simulate using pdb interactively within a simulated REPL session in a subprocess. After set_trace() was called, pdb would receive an EOF and exit before it could receive further commands.
If there's interest, I could also add the code from PR129768 to shorten the BdbQuit traceback by one frame.