Issue 16180: cannot quit pdb when there is a syntax error in the debuggee (must kill it) (original) (raw)
$ tmp=mktemp /tmp/foo.XXXXXXXXXX
; echo 'def foo: pass' > tmp;python3−mpdbtmp; python3 -m pdb tmp;python3−mpdbtmp; rm $tmp
Traceback (most recent call last):
File "/usr/local/lib/python3.2/pdb.py", line 1556, in main
pdb._runscript(mainpyfile)
File "/usr/local/lib/python3.2/pdb.py", line 1437, in _runscript
self.run(statement)
File "/usr/local/lib/python3.2/bdb.py", line 392, in run
exec(cmd, globals, locals)
File "", line 1, in
File "/tmp/foo.iLhPYHBZrF", line 1
def foo: pass
^
SyntaxError: invalid syntax
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
(1)() (Pdb) quit Post mortem debugger finished. The /tmp/foo.iLhPYHBZrF will be restarted Traceback (most recent call last): File "/usr/local/lib/python3.2/pdb.py", line 1556, in main pdb._runscript(mainpyfile) File "/usr/local/lib/python3.2/pdb.py", line 1437, in _runscript self.run(statement) File "/usr/local/lib/python3.2/bdb.py", line 392, in run exec(cmd, globals, locals) File "", line 1, in File "/tmp/foo.iLhPYHBZrF", line 1 def foo: pass ^ SyntaxError: invalid syntax Uncaught exception. Entering post mortem debugging Running 'cont' or 'step' will restart the program (1)() (Pdb) --KeyboardInterrupt-- (Pdb)
Simple fix attached. I copied the exit code from this part of the 'while True:' loop.
try:
pdb._runscript(mainpyfile)
if pdb._user_requested_quit:
break
print("The program finished and will be restarted")
I am not sure if the conditional is still needed there.
Xavier, if you have a better patch, please upload it.