Commits

Anonymous committed 808e656

- Use a flag instead of a function object (makes the intention clearer)
- Always print the traceback, not only when the user decides to
quit. It's always a bug in the program when this happens, so I don't
care about the stdout/Console.app clutter.
- Do an NSLog() before printing the traceback.

Comments (0)

Files changed (1)

pyobjc/Lib/PyObjCTools/AppHelper.py

 """
 
 from AppKit import NSApplicationMain, NSApp, NSRunAlertPanel
+from Foundation import NSLog
 import sys
+import traceback
 
 
 def unexpectedErrorAlert():
-    import traceback
     exceptionInfo = traceback.format_exception_only(
         *sys.exc_info()[:2])[0].strip()
     return NSRunAlertPanel("An unexpected error has occurred",
     if argv is None:
         argv = sys.argv
 
-    mainFunc = NSApplicationMain
-    args = (argv,)
+    firstRun = 1
     while 1:
         try:
-            mainFunc(*args)
+            if firstRun:
+                firstRun = 0
+                NSApplicationMain(argv)
+            else:
+                NSApp().run()
         except:
+            NSLog("An exception has occured:")
             if not unexpectedErrorAlert():
                 raise
-            mainFunc = NSApp().run
-            args = ()
+            else:
+                traceback.print_exc()
         else:
             break