Skip to content

Commit

Permalink
[3.9] bpo-26053: Fix args echoed by pdb run command (GH-25149)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
miss-islington and iritkatriel authored Apr 2, 2021
1 parent 154f86f commit 2049bb2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Lib/pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -1708,7 +1708,7 @@ def main():
print("The program finished and will be restarted")
except Restart:
print("Restarting", mainpyfile, "with arguments:")
print("\t" + " ".join(args))
print("\t" + " ".join(sys.argv[1:]))
except SystemExit:
# In most cases SystemExit does not warrant a post-mortem session.
print("The program exited via sys.exit(). Exit status:", end=' ')
Expand Down
13 changes: 13 additions & 0 deletions Lib/test/test_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -1440,6 +1440,19 @@ def test_issue16180(self):
'Fail to handle a syntax error in the debuggee.'
.format(expected, stdout))

def test_issue26053(self):
# run command of pdb prompt echoes the correct args
script = "print('hello')"
commands = """
continue
run a b c
run d e f
quit
"""
stdout, stderr = self.run_pdb_script(script, commands)
res = '\n'.join([x.strip() for x in stdout.splitlines()])
self.assertRegex(res, "Restarting .* with arguments:\na b c")
self.assertRegex(res, "Restarting .* with arguments:\nd e f")

def test_readrc_kwarg(self):
script = textwrap.dedent("""
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +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 comments on commit 2049bb2

Please sign in to comment.