# HG changeset patch # User Jun Wu # Date 2017-02-16 00:22:22 # Node ID 1f803482844afd22b8dbc0846cda307214d79da9 # Parent 15f9084a9a0c7d88153d6de416c6529b702a7f04 runtests: checkportisavailable should only check one family As explained by the previous patch, checkportisavailable() should only check the preferred family - either IPv4 or IPv6, not both. This patch makes it so. diff --git a/tests/run-tests.py b/tests/run-tests.py --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -137,10 +137,11 @@ useipv6 = checkipv6available() def checkportisavailable(port): """return true if a port seems free to bind on localhost""" - families = [getattr(socket, i, None) - for i in ('AF_INET', 'AF_INET6') - if getattr(socket, i, None) is not None] - for family in families: + if useipv6: + family = socket.AF_INET6 + else: + family = socket.AF_INET + if True: try: s = socket.socket(family, socket.SOCK_STREAM) s.bind(('localhost', port))