]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-121275: Fix test_logging and test_smtplib with Python build withoud IPv6 support...
authorAN Long <aisk@users.noreply.github.com>
Thu, 25 Jul 2024 12:03:39 +0000 (20:03 +0800)
committerGitHub <noreply@github.com>
Thu, 25 Jul 2024 12:03:39 +0000 (17:33 +0530)
Fix test_logging and test_smtplib with Python build withoud IPv6 support

Lib/test/support/smtpd.py

index c2e17cad422861bd8903e32f7e8927fbe9c47517..6537679db9ad24f22c5071d8139b1efca354ffd4 100755 (executable)
@@ -633,7 +633,8 @@ class SMTPServer(asyncore.dispatcher):
                              " be set to True at the same time")
         asyncore.dispatcher.__init__(self, map=map)
         try:
-            gai_results = socket.getaddrinfo(*localaddr,
+            family = 0 if socket.has_ipv6 else socket.AF_INET
+            gai_results = socket.getaddrinfo(*localaddr, family=family,
                                              type=socket.SOCK_STREAM)
             self.create_socket(gai_results[0][0], gai_results[0][1])
             # try to re-use a server port if possible