[Python-checkins] test.pythoninfo no longer requires socket (#93191)

vstinner webhook-mailer at python.org
Tue May 24 20:11:59 EDT 2022


https://github.com/python/cpython/commit/4a31ed8a32699973ae1f779022794fdab9fa08ee
commit: 4a31ed8a32699973ae1f779022794fdab9fa08ee
branch: main
author: Victor Stinner <vstinner at python.org>
committer: vstinner <vstinner at python.org>
date: 2022-05-25T02:11:51+02:00
summary:

test.pythoninfo no longer requires socket (#93191)

test.pythoninfo no longer fails if "import socket" fails: the socket
module is now optional.

files:
M Lib/test/pythoninfo.py

diff --git a/Lib/test/pythoninfo.py b/Lib/test/pythoninfo.py
index 84e1c047f9219..eadc87a052c4a 100644
--- a/Lib/test/pythoninfo.py
+++ b/Lib/test/pythoninfo.py
@@ -543,7 +543,10 @@ def format_attr(attr, value):
 
 
 def collect_socket(info_add):
-    import socket
+    try:
+        import socket
+    except ImportError:
+        return
 
     try:
         hostname = socket.gethostname()



More information about the Python-checkins mailing list