[issue32331] apply SOCK_TYPE_MASK to socket.type on Linux

Christian Heimes report at bugs.python.org
Fri Dec 15 05:20:42 EST 2017


Christian Heimes <lists at cheimes.de> added the comment:

Python's handling of socket has multiple issues, see #28134 for more fun. At the moment the values of type, family and protocol are unreliable at best and dangerously wrong at worst. The attributes are only correct if and only if the socket has not been created from a file descriptor and the socket hasn't been manipulated with ioctl or setsockopt().

Now to the issue at hand. I'm -1 on applying a mask to type. You can easily work around your problem by replacing "sock.type == SOCK_STREAM" with "sock.type & SOCK_STREAM == SOCK_STREAM".

----------
nosy: +christian.heimes

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32331>
_______________________________________


More information about the Python-bugs-list mailing list