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 4a31ed8a32)

Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
Miss Islington (bot) 2022-05-24 17:42:06 -07:00 committed by GitHub
parent 502dba0cf3
commit 2d5d01f26b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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)