Kurt Rose added the comment: I was incorrect -- the result of getsockname() appears to be some garbage port:
>>> socket.create_connection( ('google.com', 2**16 + 80) ).getsockname() ('10.225.89.86', 56446) >>> socket.create_connection( ('google.com', 2**16 + 80) ).getsockname() ('10.225.89.86', 56447) >>> socket.create_connection( ('google.com', 2**16 + 80) ).getsockname() ('10.225.89.86', 56448) >>> socket.create_connection( ('google.com', 2**16 + 80) ).getsockname() ('10.225.89.86', 56449) >>> socket.create_connection( ('google.com', 2**16 + 80) ).getsockname() ('10.225.89.86', 56450) >>> socket.create_connection( ('google.com', 2**16 + 80) ).getsockname() ('10.225.89.86', 56451) >>> socket.create_connection( ('google.com', 2**16 + 80) ).getsockname() ('10.225.89.86', 56452) Java's stdlib gives a proper error message: >>> java.net.Socket("google.com", 2**16 + 80) Traceback (most recent call last): File "<stdin>", line 1, in <module> at java.net.InetSocketAddress.<init>(Unknown Source) at java.net.Socket.<init>(Unknown Source) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Sou rce) at java.lang.reflect.Constructor.newInstance(Unknown Source) at org.python.core.PyReflectedConstructor.constructProxy(PyReflectedCons tructor.java:210) java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: port out of range:65616 The .NET runtime also rejects invalid ports: >>> System.Net.IPEndPoint(0x7F000001, 2**16 + 80) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: Specified argument was out of the range of valid values. Parameter name: port IronPython by extension rejects the invalid port: >>> socket.create_connection( ('google.com', 2**16 + 80) ) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: Specified argument was out of the range of valid values. Parameter name: port However, Jython recreates the behavior of CPython: >>> socket.create_connection( ('google.com', 2**16 + 80) ).getsockname() (u'10.225.89.86', 63071) ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue24169> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com