From: AN Long Date: Thu, 25 Jul 2024 12:03:39 +0000 (+0800) Subject: gh-121275: Fix test_logging and test_smtplib with Python build withoud IPv6 support... X-Git-Tag: v3.14.0a1~990 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3998554bb05f5ce18e8a66492d23d094a2299442;p=thirdparty%2FPython%2Fcpython.git gh-121275: Fix test_logging and test_smtplib with Python build withoud IPv6 support (#121276) Fix test_logging and test_smtplib with Python build withoud IPv6 support --- diff --git a/Lib/test/support/smtpd.py b/Lib/test/support/smtpd.py index c2e17cad4228..6537679db9ad 100755 --- a/Lib/test/support/smtpd.py +++ b/Lib/test/support/smtpd.py @@ -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