summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorYury Selivanov <yury@magic.io>2017-12-19 01:02:54 (GMT)
committerGitHub <noreply@github.com>2017-12-19 01:02:54 (GMT)
commit9818142b1bd20243733a953fb8aa2c7be314c47c (patch)
tree625350fae6c199ae5442118eaf36db480fe00046 /Doc
parent6efcb6d3d5911aaf699f9df3bb3bc26e94f38e6d (diff)
downloadcpython-9818142b1bd20243733a953fb8aa2c7be314c47c.zip
cpython-9818142b1bd20243733a953fb8aa2c7be314c47c.tar.gz
cpython-9818142b1bd20243733a953fb8aa2c7be314c47c.tar.bz2
bpo-32331: Fix socket.type when SOCK_NONBLOCK is available (#4877)
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/socket.rst22
-rw-r--r--Doc/whatsnew/3.7.rst7
2 files changed, 29 insertions, 0 deletions
diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst
index 42fd7ea..db032ca 100644
--- a/Doc/library/socket.rst
+++ b/Doc/library/socket.rst
@@ -482,6 +482,20 @@ The following functions all create :ref:`socket objects <socket-objects>`.
.. versionchanged:: 3.7
The CAN_ISOTP protocol was added.
+ .. versionchanged:: 3.7
+ When :const:`SOCK_NONBLOCK` or :const:`SOCK_CLOEXEC`
+ bit flags are applied to *type* they are cleared, and
+ :attr:`socket.type` will not reflect them. They are still passed
+ to the underlying system `socket()` call. Therefore::
+
+ sock = socket.socket(
+ socket.AF_INET,
+ socket.SOCK_STREAM | socket.SOCK_NONBLOCK)
+
+ will still create a non-blocking socket on OSes that support
+ ``SOCK_NONBLOCK``, but ``sock.type`` will be set to
+ ``socket.SOCK_STREAM``.
+
.. function:: socketpair([family[, type[, proto]]])
Build a pair of connected socket objects using the given address family, socket
@@ -1417,6 +1431,10 @@ to sockets.
* ``sock.setblocking(False)`` is equivalent to ``sock.settimeout(0.0)``
+ .. versionchanged:: 3.7
+ The method no longer applies :const:`SOCK_NONBLOCK` flag on
+ :attr:`socket.type`.
+
.. method:: socket.settimeout(value)
@@ -1429,6 +1447,10 @@ to sockets.
For further information, please consult the :ref:`notes on socket timeouts <socket-timeouts>`.
+ .. versionchanged:: 3.7
+ The method no longer toggles :const:`SOCK_NONBLOCK` flag on
+ :attr:`socket.type`.
+
.. method:: socket.setsockopt(level, optname, value: int)
.. method:: socket.setsockopt(level, optname, value: buffer)
diff --git a/Doc/whatsnew/3.7.rst b/Doc/whatsnew/3.7.rst
index 82f7cc0..e5523ff 100644
--- a/Doc/whatsnew/3.7.rst
+++ b/Doc/whatsnew/3.7.rst
@@ -892,6 +892,13 @@ Changes in the Python API
recent to be more consistent with :mod:`traceback`.
(Contributed by Jesse Bakker in :issue:`32121`.)
+* On OSes that support :const:`socket.SOCK_NONBLOCK` or
+ :const:`socket.SOCK_CLOEXEC` bit flags, the
+ :attr:`socket.type <socket.socket.type>` no longer has them applied.
+ Therefore, checks like ``if sock.type == socket.SOCK_STREAM``
+ work as expected on all platforms.
+ (Contributed by Yury Selivanov in :issue:`32331`.)
+
.. _Unicode Technical Standard #18: https://unicode.org/reports/tr18/
* On Windows the default for the *close_fds* argument of