Added a Tk error dialog to run.py inform the user if the subprocess can't
connect to the user GUI process.  Added a timeout to the GUI's listening
socket.  Added Tk error dialogs to PyShell.py to announce a failure to bind
the port or connect to the subprocess.  Clean up error handling during
connection initiation phase.  This is an update of Python Patch 778323.

M NEWS.txt
M PyShell.py
M ScriptBinding.py
M run.py

Backport candidate.
diff --git a/Lib/idlelib/run.py b/Lib/idlelib/run.py
index 8cfa808..96da459 100644
--- a/Lib/idlelib/run.py
+++ b/Lib/idlelib/run.py
@@ -47,6 +47,7 @@
     global no_exitfunc
     no_exitfunc = del_exitfunc
     port = 8833
+    #time.sleep(15) # test subprocess not responding
     if sys.argv[1:]:
         port = int(sys.argv[1])
     sys.argv[:] = [""]
@@ -90,24 +91,38 @@
                 continue
 
 def manage_socket(address):
-    for i in range(6):
+    for i in range(3):
         time.sleep(i)
         try:
             server = MyRPCServer(address, MyHandler)
             break
         except socket.error, err:
-            if i < 3:
-                print>>sys.__stderr__, ".. ",
-            else:
-                print>>sys.__stderr__,"\nPython subprocess socket error: "\
-                                              + err[1] + ", retrying...."
+            print>>sys.__stderr__,"IDLE Subprocess: socket error: "\
+                                        + err[1] + ", retrying...."
     else:
-        print>>sys.__stderr__, "\nConnection to Idle failed, exiting."
+        print>>sys.__stderr__, "IDLE Subprocess: Connection to "\
+                               "IDLE GUI failed, exiting."
+        show_socket_error(err, address)
         global exit_now
         exit_now = True
         return
     server.handle_request() # A single request only
 
+def show_socket_error(err, address):
+    import Tkinter
+    import tkMessageBox
+    root = Tkinter.Tk()
+    root.withdraw()
+    if err[0] == 61: # connection refused
+        msg = "IDLE's subprocess can't connect to %s:%d.  This may be due "\
+              "to your personal firewall configuration.  It is safe to "\
+              "allow this internal connection because no data is visible on "\
+              "external ports." % address
+        tkMessageBox.showerror("IDLE Subprocess Error", msg, parent=root)
+    else:
+        tkMessageBox.showerror("IDLE Subprocess Error", "Socket Error: %s" % err[1])
+    root.destroy()
+
 def print_exception():
     import linecache
     linecache.checkcache()
@@ -116,7 +131,7 @@
     typ, val, tb = excinfo = sys.exc_info()
     sys.last_type, sys.last_value, sys.last_traceback = excinfo
     tbe = traceback.extract_tb(tb)
-    print >>efile, '\nTraceback (most recent call last):'
+    print>>efile, '\nTraceback (most recent call last):'
     exclude = ("run.py", "rpc.py", "threading.py", "Queue.py",
                "RemoteDebugger.py", "bdb.py")
     cleanup_traceback(tbe, exclude)