summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-05-24 17:42:06 -0700
committerGitHub <noreply@github.com>2022-05-24 17:42:06 -0700
commit2d5d01f26ba7939e8a035b6fe7abcc8490c9f208 (patch)
tree5f9c36b6e1364e1f268c5b0668589f760c76d681
parent502dba0cf38ebd657d444fd49b8d648fe86bbb7d (diff)
downloadcpython-git-2d5d01f26ba7939e8a035b6fe7abcc8490c9f208.tar.gz
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@python.org>
-rw-r--r--Lib/test/pythoninfo.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/test/pythoninfo.py b/Lib/test/pythoninfo.py
index 8c8011b550..005eae549c 100644
--- a/Lib/test/pythoninfo.py
+++ b/Lib/test/pythoninfo.py
@@ -532,7 +532,10 @@ def collect_ssl(info_add):
def collect_socket(info_add):
- import socket
+ try:
+ import socket
+ except ImportError:
+ return
hostname = socket.gethostname()
info_add('socket.hostname', hostname)