[Python-checkins] Use IPv4 only to avoid IP address collision (#7030)

Andrew Svetlov webhook-mailer at python.org
Mon May 21 08:06:28 EDT 2018


https://github.com/python/cpython/commit/b7555babe95ee0db2f1224ec53cfe68a005448a1
commit: b7555babe95ee0db2f1224ec53cfe68a005448a1
branch: master
author: Andrew Svetlov <andrew.svetlov at gmail.com>
committer: GitHub <noreply at github.com>
date: 2018-05-21T15:06:26+03:00
summary:

Use IPv4 only to avoid IP address collision (#7030)

files:
M Lib/test/test_asyncio/test_base_events.py

diff --git a/Lib/test/test_asyncio/test_base_events.py b/Lib/test/test_asyncio/test_base_events.py
index a14c55693539..8566a9d5504f 100644
--- a/Lib/test/test_asyncio/test_base_events.py
+++ b/Lib/test/test_asyncio/test_base_events.py
@@ -1848,15 +1848,13 @@ def run_loop(self, coro):
     def prepare(self):
         sock = self.make_socket()
         proto = self.MyProto(self.loop)
-        af = socket.AF_UNSPEC if support.IPV6_ENABLED else socket.AF_INET
         server = self.run_loop(self.loop.create_server(
-            lambda: proto, support.HOST, 0, family=af))
-        port = server.sockets[0].getsockname()[1]
+            lambda: proto, support.HOST, 0, family=socket.AF_INET))
+        addr = server.sockets[0].getsockname()
 
         for _ in range(10):
             try:
-                self.run_loop(self.loop.sock_connect(sock,
-                                                     (support.HOST, port)))
+                self.run_loop(self.loop.sock_connect(sock, addr))
             except OSError:
                 self.run_loop(asyncio.sleep(0.5))
                 continue
@@ -1864,7 +1862,7 @@ def prepare(self):
                 break
         else:
             # One last try, so we get the exception
-            self.run_loop(self.loop.sock_connect(sock, (support.HOST, port)))
+            self.run_loop(self.loop.sock_connect(sock, addr))
 
         def cleanup():
             server.close()



More information about the Python-checkins mailing list