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

miss-islington webhook-mailer at python.org
Tue May 24 20:42:10 EDT 2022


https://github.com/python/cpython/commit/2d5d01f26ba7939e8a035b6fe7abcc8490c9f208
commit: 2d5d01f26ba7939e8a035b6fe7abcc8490c9f208
branch: 3.10
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2022-05-24T17:42:06-07:00
summary:

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 <vstinner at python.org>

files:
M Lib/test/pythoninfo.py

diff --git a/Lib/test/pythoninfo.py b/Lib/test/pythoninfo.py
index 8c8011b550acd..005eae549cb04 100644
--- a/Lib/test/pythoninfo.py
+++ b/Lib/test/pythoninfo.py
@@ -532,7 +532,10 @@ def format_attr(attr, value):
 
 
 def collect_socket(info_add):
-    import socket
+    try:
+        import socket
+    except ImportError:
+        return
 
     hostname = socket.gethostname()
     info_add('socket.hostname', hostname)



More information about the Python-checkins mailing list