Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e245ed7

Browse filesBrowse files
gh-118714: Make the pdb post-mortem restart/quit behavior more reasonable (#118725)
1 parent f8373db commit e245ed7
Copy full SHA for e245ed7

File tree

Expand file treeCollapse file tree

3 files changed

+25
-3
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+25
-3
lines changed

‎Lib/pdb.py

Copy file name to clipboardExpand all lines: Lib/pdb.py
+6-3Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2481,9 +2481,12 @@ def main():
24812481
traceback.print_exception(e, colorize=_colorize.can_colorize())
24822482
print("Uncaught exception. Entering post mortem debugging")
24832483
print("Running 'cont' or 'step' will restart the program")
2484-
pdb.interaction(None, e)
2485-
print(f"Post mortem debugger finished. The {target} will "
2486-
"be restarted")
2484+
try:
2485+
pdb.interaction(None, e)
2486+
except Restart:
2487+
print("Restarting", target, "with arguments:")
2488+
print("\t" + " ".join(sys.argv[1:]))
2489+
continue
24872490
if pdb._user_requested_quit:
24882491
break
24892492
print("The program finished and will be restarted")

‎Lib/test/test_pdb.py

Copy file name to clipboardExpand all lines: Lib/test/test_pdb.py
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3545,6 +3545,23 @@ def change_file(content, filename):
35453545
# the file as up to date
35463546
self.assertNotIn("WARNING:", stdout)
35473547

3548+
def test_post_mortem_restart(self):
3549+
script = """
3550+
def foo():
3551+
raise ValueError("foo")
3552+
foo()
3553+
"""
3554+
3555+
commands = """
3556+
continue
3557+
restart
3558+
continue
3559+
quit
3560+
"""
3561+
3562+
stdout, stderr = self.run_pdb_script(script, commands)
3563+
self.assertIn("Restarting", stdout)
3564+
35483565
def test_relative_imports(self):
35493566
self.module_name = 't_main'
35503567
os_helper.rmtree(self.module_name)
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Allow ``restart`` in post-mortem debugging of :mod:`pdb`. Removed restart message
2+
when the user quits pdb from post-mortem mode.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.