Author yselivanov
Recipients asvetlov, christian.heimes, inada.naoki, pitrou, vstinner, yselivanov
Date 2017-12-15.16:38:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1513355932.76.0.213398074469.issue32331@psf.upfronthosting.co.za>
In-reply-to
Content
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 a utility function or a property reporting the "masked" type?

I agree.   Here's what I propose:

1. We don't touch `socket.type`.  We don't know what kind of code exists out there and in what ways it will break.  The ship has sailed to fix it.

2. We add `socket.SOCK_TYPE_MASK` (on Linux).

3. We fix `socket.__repr__` to correctly render type.  Currently:

    >>> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM | socket.SOCK_NONBLOCK)
    >>> s
    <socket.socket fd=3, family=AddressFamily.AF_INET, type=2049, proto=0, laddr=('0.0.0.0', 0)>

What I want to see:

    <socket.socket fd=3, family=AddressFamily.AF_INET, type=SOCK_STREAM | SOCK_NONBLOCK, proto=0, laddr=('0.0.0.0', 0)>

4. We add `socket.true_type` which will apply `SOCK_TYPE_MASK` and return a socket type that's safe to compare to `socket.SOCK_*` constants.

Thoughts?
History
Date User Action Args
2017-12-15 16:38:52yselivanovsetrecipients: + yselivanov, pitrou, vstinner, christian.heimes, asvetlov, inada.naoki
2017-12-15 16:38:52yselivanovsetmessageid: <1513355932.76.0.213398074469.issue32331@psf.upfronthosting.co.za>
2017-12-15 16:38:52yselivanovlinkissue32331 messages
2017-12-15 16:38:52yselivanovcreate