Skip to content

Commit 2049bb2

Browse files
[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) (cherry picked from commit 7ad56e2) Co-authored-by: Irit Katriel <iritkatriel@yahoo.com>
1 parent 154f86f commit 2049bb2

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
@@ -1440,6 +1440,19 @@ def test_issue16180(self):
14401440
'Fail to handle a syntax error in the debuggee.'
14411441
.format(expected, stdout))
14421442

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

14441457
def test_readrc_kwarg(self):
14451458
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)