File tree Expand file tree Collapse file tree 3 files changed +20
-7
lines changed
Expand file tree Collapse file tree 3 files changed +20
-7
lines changed Original file line number Diff line number Diff line change @@ -2151,26 +2151,23 @@ def main():
21512151 while True :
21522152 try :
21532153 pdb ._run (target )
2154- if pdb ._user_requested_quit :
2155- break
2156- print ("The program finished and will be restarted" )
21572154 except Restart :
21582155 print ("Restarting" , target , "with arguments:" )
21592156 print ("\t " + " " .join (sys .argv [1 :]))
21602157 except SystemExit as e :
21612158 # In most cases SystemExit does not warrant a post-mortem session.
21622159 print ("The program exited via sys.exit(). Exit status:" , end = ' ' )
21632160 print (e )
2164- except SyntaxError :
2165- traceback .print_exc ()
2166- sys .exit (1 )
21672161 except BaseException as e :
21682162 traceback .print_exc ()
21692163 print ("Uncaught exception. Entering post mortem debugging" )
21702164 print ("Running 'cont' or 'step' will restart the program" )
21712165 pdb .interaction (None , e )
21722166 print ("Post mortem debugger finished. The " + target +
21732167 " will be restarted" )
2168+ if pdb ._user_requested_quit :
2169+ break
2170+ print ("The program finished and will be restarted" )
21742171
21752172
21762173# When invoked as main program, invoke the debugger on a script
Original file line number Diff line number Diff line change @@ -2638,13 +2638,28 @@ def test_issue16180(self):
26382638 commands = ''
26392639 expected = "SyntaxError:"
26402640 stdout , stderr = self .run_pdb_script (
2641- script , commands , expected_returncode = 1
2641+ script , commands
26422642 )
26432643 self .assertIn (expected , stdout ,
26442644 '\n \n Expected:\n {}\n Got:\n {}\n '
26452645 'Fail to handle a syntax error in the debuggee.'
26462646 .format (expected , stdout ))
26472647
2648+ def test_issue84583 (self ):
2649+ # A syntax error from ast.literal_eval should not make pdb exit.
2650+ script = "import ast; ast.literal_eval('')\n "
2651+ commands = """
2652+ continue
2653+ where
2654+ quit
2655+ """
2656+ stdout , stderr = self .run_pdb_script (script , commands )
2657+ # The code should appear 3 times in the stdout:
2658+ # 1. when pdb starts
2659+ # 2. when the exception is raised, in trackback
2660+ # 3. in where command
2661+ self .assertEqual (stdout .count ("ast.literal_eval('')" ), 3 )
2662+
26482663 def test_issue26053 (self ):
26492664 # run command of pdb prompt echoes the correct args
26502665 script = "print('hello')"
Original file line number Diff line number Diff line change 1+ Make :mod: `pdb ` enter post-mortem mode even for :exc: `SyntaxError `
You can’t perform that action at this time.
0 commit comments