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 e7008d7

Browse filesBrowse files
[3.13] gh-118714: Make the pdb post-mortem restart/quit behavior more reasonable (GH-118725) (#121346)
gh-118714: Make the pdb post-mortem restart/quit behavior more reasonable (GH-118725) (cherry picked from commit e245ed7) Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
1 parent 3d4e533 commit e7008d7
Copy full SHA for e7008d7

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
@@ -2460,9 +2460,12 @@ def main():
24602460
traceback.print_exception(e, colorize=_colorize.can_colorize())
24612461
print("Uncaught exception. Entering post mortem debugging")
24622462
print("Running 'cont' or 'step' will restart the program")
2463-
pdb.interaction(None, e)
2464-
print(f"Post mortem debugger finished. The {target} will "
2465-
"be restarted")
2463+
try:
2464+
pdb.interaction(None, e)
2465+
except Restart:
2466+
print("Restarting", target, "with arguments:")
2467+
print("\t" + " ".join(sys.argv[1:]))
2468+
continue
24662469
if pdb._user_requested_quit:
24672470
break
24682471
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
@@ -3492,6 +3492,23 @@ def change_file(content, filename):
34923492
# the file as up to date
34933493
self.assertNotIn("WARNING:", stdout)
34943494

3495+
def test_post_mortem_restart(self):
3496+
script = """
3497+
def foo():
3498+
raise ValueError("foo")
3499+
foo()
3500+
"""
3501+
3502+
commands = """
3503+
continue
3504+
restart
3505+
continue
3506+
quit
3507+
"""
3508+
3509+
stdout, stderr = self.run_pdb_script(script, commands)
3510+
self.assertIn("Restarting", stdout)
3511+
34953512
def test_relative_imports(self):
34963513
self.module_name = 't_main'
34973514
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.