[3.6]bpo-25514: Improve IDLE's connection refused message (#2177) (#2178)
When IDLE fail to start because the socket connection fails, direct people to a new subsection of the IDLE doc listing various causes and remedies.
(cherry picked from commit 188aedf8bb623d41302e10503268b0852ea91134)
diff --git a/Lib/idlelib/run.py b/Lib/idlelib/run.py
index 12c339f..9f6604b 100644
--- a/Lib/idlelib/run.py
+++ b/Lib/idlelib/run.py
@@ -180,19 +180,16 @@
server.handle_request() # A single request only
def show_socket_error(err, address):
+ "Display socket error from manage_socket."
import tkinter
- import tkinter.messagebox as tkMessageBox
+ from tkinter.messagebox import showerror
root = tkinter.Tk()
root.withdraw()
- if err.args[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.args[1], parent=root)
+ msg = f"IDLE's subprocess can't connect to {address[0]}:{address[1]}.\n"\
+ f"Fatal OSError #{err.errno}: {err.strerror}.\n"\
+ f"See the 'Startup failure' section of the IDLE doc, online at\n"\
+ f"https://docs.python.org/3/library/idle.html#startup-failure"
+ showerror("IDLE Subprocess Error", msg, parent=root)
root.destroy()
def print_exception():