]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
test.pythoninfo no longer requires socket (GH-93191)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 25 May 2022 00:42:06 +0000 (17:42 -0700)
committerGitHub <noreply@github.com>
Wed, 25 May 2022 00:42:06 +0000 (17:42 -0700)
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>
Lib/test/pythoninfo.py

index 8c8011b550acdc3ebf7a7e8d5908b1126e075b60..005eae549cb045dc100c695ae9e07a888f8660b6 100644 (file)
@@ -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)