summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorRoss Lagerwall <rosslagerwall@gmail.com>2012-07-07 16:42:57 (GMT)
committerRoss Lagerwall <rosslagerwall@gmail.com>2012-07-07 16:42:57 (GMT)
commit5aa43542974c32b5a2a16acf42204e7a3cfcade9 (patch)
tree7849137211bfb810a4e1b9fecbc18a90afa83076 /Lib
parentd94adb73673d94530eb9cb302214e374640dc25c (diff)
parent121d59ffa98d20b20e849b4c7333a723803f6798 (diff)
downloadcpython-5aa43542974c32b5a2a16acf42204e7a3cfcade9.zip
cpython-5aa43542974c32b5a2a16acf42204e7a3cfcade9.tar.gz
cpython-5aa43542974c32b5a2a16acf42204e7a3cfcade9.tar.bz2
Merge with remote.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/support.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/test/support.py b/Lib/test/support.py
index ddd3ab6..2d7f70d 100644
--- a/Lib/test/support.py
+++ b/Lib/test/support.py
@@ -493,14 +493,16 @@ def bind_port(sock, host=HOST):
def _is_ipv6_enabled():
"""Check whether IPv6 is enabled on this host."""
if socket.has_ipv6:
+ sock = None
try:
sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
sock.bind(('::1', 0))
+ return True
except (socket.error, socket.gaierror):
pass
- else:
- sock.close()
- return True
+ finally:
+ if sock:
+ sock.close()
return False
IPV6_ENABLED = _is_ipv6_enabled()