summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2017-01-07 14:23:33 +0300
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2017-01-07 14:23:33 +0300
commita1a8f01799c7a638db52ae008e85143c4b3f215a (patch)
tree45dc7c328f60f6a0ea110cfbc2d89816cb641cf6
parentef1bbada96f392aa552f51828cb5389d400c1089 (diff)
downloadmicropython-a1a8f01799c7a638db52ae008e85143c4b3f215a.tar.gz
micropython-a1a8f01799c7a638db52ae008e85143c4b3f215a.zip
docs/usocket: Clarify that socket timeout raises OSError exception.
-rw-r--r--docs/library/usocket.rst10
1 files changed, 9 insertions, 1 deletions
diff --git a/docs/library/usocket.rst b/docs/library/usocket.rst
index e3b2b45014..c46e8f4c53 100644
--- a/docs/library/usocket.rst
+++ b/docs/library/usocket.rst
@@ -149,10 +149,18 @@ Methods
Set a timeout on blocking socket operations. The value argument can be a nonnegative floating
point number expressing seconds, or None. If a non-zero value is given, subsequent socket operations
- will raise a timeout exception if the timeout period value has elapsed before the operation has
+ will raise an ``OSError`` exception if the timeout period value has elapsed before the operation has
completed. If zero is given, the socket is put in non-blocking mode. If None is given, the socket
is put in blocking mode.
+ .. admonition:: Difference to CPython
+ :class: attention
+
+ CPython raises a ``socket.timeout`` exception in case of timeout,
+ which is an ``OSError`` subclass. MicroPython raises an OSError directly
+ instead. If you use ``except OSError:`` to catch the exception,
+ your code will work both in MicroPython and CPython.
+
.. method:: socket.setblocking(flag)
Set blocking or non-blocking mode of the socket: if flag is false, the socket is set to non-blocking,