Christian Heimes <li...@cheimes.de> added the comment:

Yuri,

* The patch is purely about Python's view of the socket. The actual behavior of 
the OS socket fd is not influenced by socket.socket()'s family, type and 
protocol. However the especially the family is critical for Python because a 
lot of socket code uses the family to decide how to format its address or the 
peer address.

* On some platforms and/or for some socket types, it is not possible to get the 
address family or type unless connect() or bind() have been called. On Linux it 
seems to work for both new sockets and bound/connected sockets. On Windows it 
never works for a fresh socket.

* It looks like Windows doesn't have protocol dedicated and always uses 0 as 
protocols.

* Using the wrong type is less of an issue. Using the wrong family is really 
really bad, see https://bugs.python.org/issue28134#msg285972.

* I don't care much about validating the values. I'm concerned to have correct 
values by default. Validation can be implemented in a separate PR. In that case 
we want to add socket.closefd(fd: int). On Windows os.close() can't be used for 
socket fds.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue28134>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to