[issue32331] apply SOCK_TYPE_MASK to socket.type on Linux
Yury Selivanov
report at bugs.python.org
Fri Dec 15 11:32:58 EST 2017
Yury Selivanov <yselivanov at gmail.com> added the comment:
> You can easily work around your problem by replacing "sock.type == SOCK_STREAM" with "sock.type & SOCK_STREAM == SOCK_STREAM".
Heh :) No, that would be a buggy code. Try this on your Linux box:
(socket.SOCK_SEQPACKET & socket.SOCK_STREAM) == socket.SOCK_STREAM
The _only_ way of checking socket type reliably is to explicitly reset SOCK_NONBLOCK and SOCK_CLOEXEC or to apply 0xF mask on Linux, and don't do that on other platforms.
That's why I think it's important to fix this one way or another.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32331>
_______________________________________
More information about the Python-bugs-list
mailing list