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():
2151
2151
while True :
2152
2152
try :
2153
2153
pdb ._run (target )
2154
- if pdb ._user_requested_quit :
2155
- break
2156
- print ("The program finished and will be restarted" )
2157
2154
except Restart :
2158
2155
print ("Restarting" , target , "with arguments:" )
2159
2156
print ("\t " + " " .join (sys .argv [1 :]))
2160
2157
except SystemExit as e :
2161
2158
# In most cases SystemExit does not warrant a post-mortem session.
2162
2159
print ("The program exited via sys.exit(). Exit status:" , end = ' ' )
2163
2160
print (e )
2164
- except SyntaxError :
2165
- traceback .print_exc ()
2166
- sys .exit (1 )
2167
2161
except BaseException as e :
2168
2162
traceback .print_exc ()
2169
2163
print ("Uncaught exception. Entering post mortem debugging" )
2170
2164
print ("Running 'cont' or 'step' will restart the program" )
2171
2165
pdb .interaction (None , e )
2172
2166
print ("Post mortem debugger finished. The " + target +
2173
2167
" will be restarted" )
2168
+ if pdb ._user_requested_quit :
2169
+ break
2170
+ print ("The program finished and will be restarted" )
2174
2171
2175
2172
2176
2173
# 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):
2638
2638
commands = ''
2639
2639
expected = "SyntaxError:"
2640
2640
stdout , stderr = self .run_pdb_script (
2641
- script , commands , expected_returncode = 1
2641
+ script , commands
2642
2642
)
2643
2643
self .assertIn (expected , stdout ,
2644
2644
'\n \n Expected:\n {}\n Got:\n {}\n '
2645
2645
'Fail to handle a syntax error in the debuggee.'
2646
2646
.format (expected , stdout ))
2647
2647
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
+
2648
2663
def test_issue26053 (self ):
2649
2664
# run command of pdb prompt echoes the correct args
2650
2665
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