[issue28134] socket.socket(fileno=fd) does not work as documented
Martin Panter
report at bugs.python.org
Tue Sep 13 20:07:59 EDT 2016
Martin Panter added the comment:
The documentation says that the family, type and proto attributes correspond to the constructor arguments. Although it is unfortunate and quirky, I think your behaviour does match the documentation.
Do the mismatched settings cause any serious problems with socket methods, or just affect the Python-level attributes and repr()?
Even without using fileno=..., you could argue that the proto attribute is not ideal:
>>> s = socket()
>>> s.proto
0
>>> s.getsockopt(SOL_SOCKET, SO_PROTOCOL)
6
>>> IPPROTO_TCP
6
Perhaps the way forward is to deprecate fileno=... in favour of Neil’s fromfd2() function. That would avoid any confusion about conflicting socket() constructor arguments and defaults. I.e. what does socket(AF_INET, SOCK_STREAM, fileno=unix_datagram_fd) mean, and is it equivalent to socket(filno=unix_datagram_fd)?
----------
nosy: +martin.panter
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28134>
_______________________________________
More information about the Python-bugs-list
mailing list