Issue #16180: Exit pdb if file has syntax error, instead of trapping user
in an infinite loop.  Patch by Xavier de Gaye.
diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py
index b6dd2b7..b98fe19 100644
--- a/Lib/test/test_pdb.py
+++ b/Lib/test/test_pdb.py
@@ -69,6 +69,17 @@
             any('main.py(5)foo()->None' in l for l in stdout.splitlines()),
             'Fail to step into the caller after a return')
 
+    def test_issue16180(self):
+        # A syntax error in the debuggee.
+        script = "def f: pass\n"
+        commands = ''
+        expected = "SyntaxError:"
+        stdout, stderr = self.run_pdb(script, commands)
+        self.assertIn(expected, stdout,
+            '\n\nExpected:\n{}\nGot:\n{}\n'
+            'Fail to handle a syntax error in the debuggee.'
+            .format(expected, stdout))
+
 
 class PdbTestInput(object):
     """Context manager that makes testing Pdb in doctests easier."""