This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author yselivanov
Recipients asvetlov, christian.heimes, methane, pitrou, vstinner, yselivanov
Date 2017-12-15.16:38:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
On GH (, 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)>

What I want to see:

    <socket.socket fd=3, family=AddressFamily.AF_INET, type=SOCK_STREAM | SOCK_NONBLOCK, proto=0, laddr=('', 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.

Date User Action Args
2017-12-15 16:38:52yselivanovsetrecipients: + yselivanov, pitrou, vstinner, christian.heimes, asvetlov, methane
2017-12-15 16:38:52yselivanovsetmessageid: <>
2017-12-15 16:38:52yselivanovlinkissue32331 messages
2017-12-15 16:38:52yselivanovcreate