[issue32331] apply SOCK_TYPE_MASK to socket.type on Linux

2017-12-15 Thread Christian Heimes
Christian Heimes added the comment: Should socket.true_type use getsockopt(fd, ...) to get the actual type? While we are talking about socket types, please have a look at #28134 . -- ___ Python tracker _

[issue32331] apply SOCK_TYPE_MASK to socket.type on Linux

2017-12-15 Thread Yury Selivanov
Yury Selivanov added the comment: On GH (https://github.com/python/cpython/pull/4877), Antoine wrote: > I agree with Victor: > it can't go into 3.6 > making the change in 3.7 is contentious > Can there be an other way to solve the issue? Can we for example keep > socket.type as it is and add

[issue32331] apply SOCK_TYPE_MASK to socket.type on Linux

2017-12-15 Thread Yury Selivanov
Yury Selivanov 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.S

[issue32331] apply SOCK_TYPE_MASK to socket.type on Linux

2017-12-15 Thread Christian Heimes
Christian Heimes 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 cre

[issue32331] apply SOCK_TYPE_MASK to socket.type on Linux

2017-12-15 Thread INADA Naoki
INADA Naoki added the comment: Document of socket.type says: The socket type. https://docs.python.org/3/library/socket.html#socket.socket.type OK, so, are SOCK_CLOEXEC and SOCK_NONBLOCK socket type? These two constants, if defined, can be combined with the socket types and allow you t

[issue32331] apply SOCK_TYPE_MASK to socket.type on Linux

2017-12-15 Thread INADA Naoki
INADA Naoki added the comment: Should we backport it to 3.6? -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe

[issue32331] apply SOCK_TYPE_MASK to socket.type on Linux

2017-12-14 Thread Yury Selivanov
Change by Yury Selivanov : -- keywords: +patch pull_requests: +4771 stage: -> patch review ___ Python tracker ___ ___ Python-bugs-li

[issue32331] apply SOCK_TYPE_MASK to socket.type on Linux

2017-12-14 Thread Yury Selivanov
New submission from Yury Selivanov : 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