From 7a5f190c9fa7c6cbd334dfea9ae6032ac886dd89 Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Tue, 24 May 2022 17:41:02 -0700 Subject: [PATCH] test.pythoninfo no longer requires socket (GH-93191) test.pythoninfo no longer fails if "import socket" fails: the socket module is now optional. (cherry picked from commit 4a31ed8a32699973ae1f779022794fdab9fa08ee) Co-authored-by: Victor Stinner --- Lib/test/pythoninfo.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Lib/test/pythoninfo.py b/Lib/test/pythoninfo.py index 84e1c047f92..eadc87a052c 100644 --- a/Lib/test/pythoninfo.py +++ b/Lib/test/pythoninfo.py @@ -543,7 +543,10 @@ def collect_ssl(info_add): def collect_socket(info_add): - import socket + try: + import socket + except ImportError: + return try: hostname = socket.gethostname()