This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author doughellmann
Recipients doughellmann
Date 2016-01-08.23:43:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1452296621.32.0.373600761217.issue26053@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2016-01-08 23:43:41doughellmannsetrecipients: + doughellmann
2016-01-08 23:43:41doughellmannsetmessageid: <1452296621.32.0.373600761217.issue26053@psf.upfronthosting.co.za>
2016-01-08 23:43:41doughellmannlinkissue26053 messages
2016-01-08 23:43:40doughellmanncreate