Skip to content

Commit 7ad56e2

Browse files
authored
[3.9] bpo-26053: Fix args echoed by pdb run command (GH-25149)
* bpo-26053: Fix args echoed by pdb run command (GH-22033) (cherry picked from commit 652bfde) * bpo-26053: Fix test_pdb.test_issue26053() (GH-25139) (cherry picked from commit bd4ab8e)
1 parent a217e0a commit 7ad56e2

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

Lib/pdb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1708,7 +1708,7 @@ def main():
17081708
print("The program finished and will be restarted")
17091709
except Restart:
17101710
print("Restarting", mainpyfile, "with arguments:")
1711-
print("\t" + " ".join(args))
1711+
print("\t" + " ".join(sys.argv[1:]))
17121712
except SystemExit:
17131713
# In most cases SystemExit does not warrant a post-mortem session.
17141714
print("The program exited via sys.exit(). Exit status:", end=' ')

Lib/test/test_pdb.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,6 +1443,19 @@ def test_issue16180(self):
14431443
'Fail to handle a syntax error in the debuggee.'
14441444
.format(expected, stdout))
14451445

1446+
def test_issue26053(self):
1447+
# run command of pdb prompt echoes the correct args
1448+
script = "print('hello')"
1449+
commands = """
1450+
continue
1451+
run a b c
1452+
run d e f
1453+
quit
1454+
"""
1455+
stdout, stderr = self.run_pdb_script(script, commands)
1456+
res = '\n'.join([x.strip() for x in stdout.splitlines()])
1457+
self.assertRegex(res, "Restarting .* with arguments:\na b c")
1458+
self.assertRegex(res, "Restarting .* with arguments:\nd e f")
14461459

14471460
def test_readrc_kwarg(self):
14481461
script = textwrap.dedent("""
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed bug where the :mod:`pdb` interactive run command echoed the args from the shell command line, even if those have been overridden at the pdb prompt.

0 commit comments

Comments
 (0)