Message308363
On Linux, socket type is both a socket type and a bit mask (of SOCK_CLOEXEC and SOCK_NONBLOCK). Therefore, anyone who write code like 'if sock.type == SOCK_STREAM' writes non-portable code, that occasionally breaks on Linux.
This caused some hard to spot bugs in asyncio already: https://bugs.python.org/issue27456 -- this one was discovered only 1 year after the actual change.
On Linux, in 'include/linux/net.h' there's a SOCK_TYPE_MASK macro defined to 0xF. The idea is that on Linux you should mask socket type before comparing it to SOCK_STREAM or other socket types.
Using socket.SOCK_NONBLOCK on Python was always error-prone even if one targets only Linux. For instance, socket.type won't be updated to include SOCK_NONBLOCK if the socket was updated via ioctl call directly.
Therefore, I propose to fix socket.type getter to always (on Linux) apply that mask in Python. |
|
Date |
User |
Action |
Args |
2017-12-15 03:42:49 | yselivanov | set | recipients:
+ yselivanov, pitrou, vstinner, asvetlov, methane |
2017-12-15 03:42:49 | yselivanov | set | messageid: <1513309369.41.0.213398074469.issue32331@psf.upfronthosting.co.za> |
2017-12-15 03:42:49 | yselivanov | link | issue32331 messages |
2017-12-15 03:42:47 | yselivanov | create | |
|