[issue26053] regression in pdb output between 2.7 and 3.5

Doug Hellmann report at bugs.python.org
Fri Jan 8 18:43:41 EST 2016


New submission from Doug Hellmann:

Under python 2.7 using the "run" command within pdb and passing it arguments causes those arguments to be printed out. Under 3.5, this is no longer true.



$ python2.7 -m pdb pdb_run.py
> /Users/dhellmann/Dropbox/PyMOTW/Python3/pymotw-3/source/pdb/pdb_run.py(7)<module>()
-> import sys
(Pdb) c
('Command-line args:', ['pdb_run.py'])
The program finished and will be restarted
> /Users/dhellmann/Dropbox/PyMOTW/Python3/pymotw-3/source/pdb/pdb_run.py(7)<module>()
-> import sys
(Pdb) run a b c "this is a long argument"
Restarting pdb_run.py with arguments:
	a b c this is a long argument
> /Users/dhellmann/Dropbox/PyMOTW/Python3/pymotw-3/source/pdb/pdb_run.py(7)<module>()
-> import sys



$ python3.5 -m pdb pdb_run.py
> /Users/dhellmann/Dropbox/PyMOTW/Python3/pymotw-3/source/pdb/pdb_run.py(7)<module>()
-> import sys
(Pdb) c
Command-line args: ['pdb_run.py']
The program finished and will be restarted
> /Users/dhellmann/Dropbox/PyMOTW/Python3/pymotw-3/source/pdb/pdb_run.py(7)<module>()
-> import sys
(Pdb) run a b c "this is a long argument"
Restarting pdb_run.py with arguments:
	pdb_run.py
> /Users/dhellmann/Dropbox/PyMOTW/Python3/pymotw-3/source/pdb/pdb_run.py(7)<module>()
-> import sys


It looks like the issue is in the pdb main loop. Under 2.7 the restart logic has:

except Restart:
    print "Restarting", mainpyfile, "with arguments:"
    print "\t" + " ".join(sys.argv[1:])


but under 3.5 that was changed to:

except Restart:
    print("Restarting", mainpyfile, "with arguments:")
    print("\t" + " ".join(args))


The do_run() method has already reset sys.argv before throwing Restart, so to print the correct arguments sys.argv[1:] should be used.

----------
files: pdb_run.py
keywords: 3.5regression
messages: 257785
nosy: doughellmann
priority: normal
severity: normal
status: open
title: regression in pdb output between 2.7 and 3.5
type: behavior
versions: Python 3.5, Python 3.6
Added file: http://bugs.python.org/file41538/pdb_run.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26053>
_______________________________________


More information about the Python-bugs-list mailing list