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/pdb.py b/Lib/pdb.py
index e28564b..7d58c2a 100755
--- a/Lib/pdb.py
+++ b/Lib/pdb.py
@@ -1669,6 +1669,9 @@
             # In most cases SystemExit does not warrant a post-mortem session.
             print("The program exited via sys.exit(). Exit status:", end=' ')
             print(sys.exc_info()[1])
+        except SyntaxError:
+            traceback.print_exc()
+            sys.exit(1)
         except:
             traceback.print_exc()
             print("Uncaught exception. Entering post mortem debugging")