New submission from Christian Heimes: Documentation of socket.socket(fileno) https://docs.python.org/3/library/socket.html#socket.socket says:
> If fileno is specified, the other arguments are ignored, causing the socket > with the specified file descriptor to return. The feature does not work. fileno does not infer the values for family, type and proto from the fd. Instead if uses the other arguments. I don't see how this feature should have ever worked on POSIX. There are no calls to getsockopt() with SO_DOMAIN, SO_TYPE and SO_PROTOCOL. $ ./python Python 3.7.0a0 (default:6bcedf96d25f, Sep 13 2016, 20:48:50) [GCC 6.1.1 20160621 (Red Hat 6.1.1-3)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import socket >>> uds = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) >>> uds <socket.socket fd=3, family=AddressFamily.AF_UNIX, type=SocketKind.SOCK_STREAM, proto=0> >>> s = socket.socket(fileno=uds.fileno()) >>> s <socket.socket fd=3, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0> >>> s.family == uds.family False >>> s2 = socket.socket(type=socket.SOCK_DGRAM, fileno=uds.fileno()) >>> s2 <socket.socket fd=3, family=AddressFamily.AF_INET, type=SocketKind.SOCK_DGRAM, proto=0> ---------- messages: 276327 nosy: christian.heimes priority: normal severity: normal status: open title: socket.socket(fileno=fd) does not work as documented versions: Python 3.5, Python 3.6, Python 3.7 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28134> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com