Message257785
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. |
|
Date |
User |
Action |
Args |
2016-01-08 23:43:41 | doughellmann | set | recipients:
+ doughellmann |
2016-01-08 23:43:41 | doughellmann | set | messageid: <1452296621.32.0.373600761217.issue26053@psf.upfronthosting.co.za> |
2016-01-08 23:43:41 | doughellmann | link | issue26053 messages |
2016-01-08 23:43:40 | doughellmann | create | |
|