### Eclipse Workspace Patch 1.0 #P jython-trunk Index: Lib/test/test_socket_jy.py =================================================================== --- Lib/test/test_socket_jy.py (revision 0) +++ Lib/test/test_socket_jy.py (revision 0) @@ -0,0 +1,25 @@ +import httplib +import socket +import sys +from test import test_support +import unittest + + +class SocketIPv6Test(unittest.TestCase): + + def test_create(self): + '''Ensures a correct socket.error message''' + conn = httplib.HTTPConnection('localhost', 18080) + body = "" + headers = {} + try: + conn.request("GET", "/RELEASE-NOTES.txt", body, headers) + except socket.error: + pass # used to get an AssertionError (see bug 1697) + + +def test_main(): + test_support.run_unittest(SocketIPv6Test) + +if __name__ == "__main__": + test_main() Index: Lib/socket.py =================================================================== --- Lib/socket.py (revision 7173) +++ Lib/socket.py (working copy) @@ -603,6 +603,9 @@ try: if not family in [AF_INET, AF_INET6, AF_UNSPEC]: raise gaierror(errno.EIO, 'ai_family not supported') + # reroute to AF_INET, since we currently do not support IPv6 (quick fix for bug 1697) + if not family in [AF_INET]: + family = AF_INET filter_fns = [] filter_fns.append({ AF_INET: lambda x: isinstance(x, java.net.Inet4Address), @@ -1112,6 +1115,9 @@ def __init__(self, family=AF_INET, type=SOCK_STREAM, proto=0, _sock=None): if _sock is None: + # reroute to AF_INET, since we currently do not support IPv6 (quick fix for bug 1697) + if not family in [AF_INET]: + family = AF_INET _sock = _realsocket(family, type, proto) _sock.reference_count += 1 elif isinstance(_sock, _nonblocking_api_mixin):