[issue32331] Add socket.truetype property

Nathaniel Smith report at bugs.python.org
Fri Dec 15 23:25:52 EST 2017


Nathaniel Smith <njs at pobox.com> added the comment:

Re-reading my above post, I realized I want to emphasize a little more how odd the current relationship is between socket.type and SOCK_CLOEXEC. Right now, the way it works is:

Python *always* adds SOCK_CLOEXEC to the type that it passes to the operating system when creating a socket. You can later toggle this with socket.set_inheritable, and check it with socket.get_inheritable.

You might expect that you could also check it with (socket.type | SOCK_CLOEXEC), and this does tell you *something*... but it has *no relationship at all* to whether the socket has close-on-exec enabled. Instead, what it tells you whether you passed SOCK_CLOEXEC to the socket constructor. Given that passing SOCK_CLOEXEC to the socket constructor is otherwise *completely ignored*, this seems like a weird piece of information to make available.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32331>
_______________________________________


More information about the Python-bugs-list mailing list