File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1669,6 +1669,9 @@ def main():
16691669 # In most cases SystemExit does not warrant a post-mortem session.
16701670 print ("The program exited via sys.exit(). Exit status:" , end = ' ' )
16711671 print (sys .exc_info ()[1 ])
1672+ except SyntaxError :
1673+ traceback .print_exc ()
1674+ sys .exit (1 )
16721675 except :
16731676 traceback .print_exc ()
16741677 print ("Uncaught exception. Entering post mortem debugging" )
Original file line number Diff line number Diff line change @@ -1043,6 +1043,18 @@ def start_pdb():
10431043 self .assertNotIn ('Error' , stdout .decode (),
10441044 "Got an error running test script under PDB" )
10451045
1046+ def test_issue16180 (self ):
1047+ # A syntax error in the debuggee.
1048+ script = "def f: pass\n "
1049+ commands = ''
1050+ expected = "SyntaxError:"
1051+ stdout , stderr = self .run_pdb (script , commands )
1052+ self .assertIn (expected , stdout ,
1053+ '\n \n Expected:\n {}\n Got:\n {}\n '
1054+ 'Fail to handle a syntax error in the debuggee.'
1055+ .format (expected , stdout ))
1056+
1057+
10461058 def tearDown (self ):
10471059 support .unlink (support .TESTFN )
10481060
Original file line number Diff line number Diff line change @@ -81,6 +81,9 @@ Core and Builtins
8181Library
8282-------
8383
84+ - Issue #16180: Exit pdb if file has syntax error, instead of trapping user
85+ in an infinite loop. Patch by Xavier de Gaye.
86+
8487- Issue #21112: Fix regression in unittest.expectedFailure on subclasses.
8588 Patch from Berker Peksag.
8689
You can’t perform that action at this time.
0 commit comments