This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author remi.lapeyre
Recipients Kerrick Staley, remi.lapeyre, terry.reedy, xdegaye
Date 2020-06-01.21:00:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1591045205.86.0.523577876494.issue40403@roundup.psfhosted.org>
In-reply-to
Content
This is related to issue 16180, it may be possible to improve the situation by trying to determine whether the SyntaxError is in the file or came during its execution by looking at the filename but it's probably very brittle:



             # 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:
+        except Exception as e:
+            if (type(e) is SyntaxError and
+                e.filename == os.path.abspath(mainpyfile)):
+                traceback.print_exc()
+                sys.exit(1)
             traceback.print_exc()
             print("Uncaught exception. Entering post mortem debugging")
             print("Running 'cont' or 'step' will restart the program")
History
Date User Action Args
2020-06-01 21:00:05remi.lapeyresetrecipients: + remi.lapeyre, terry.reedy, xdegaye, Kerrick Staley
2020-06-01 21:00:05remi.lapeyresetmessageid: <1591045205.86.0.523577876494.issue40403@roundup.psfhosted.org>
2020-06-01 21:00:05remi.lapeyrelinkissue40403 messages
2020-06-01 21:00:05remi.lapeyrecreate