File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -149,10 +149,18 @@ Methods
149149
150150 Set a timeout on blocking socket operations. The value argument can be a nonnegative floating
151151 point number expressing seconds, or None. If a non-zero value is given, subsequent socket operations
152- will raise a timeout exception if the timeout period value has elapsed before the operation has
152+ will raise an `` OSError `` exception if the timeout period value has elapsed before the operation has
153153 completed. If zero is given, the socket is put in non-blocking mode. If None is given, the socket
154154 is put in blocking mode.
155155
156+ .. admonition :: Difference to CPython
157+ :class: attention
158+
159+ CPython raises a ``socket.timeout `` exception in case of timeout,
160+ which is an ``OSError `` subclass. MicroPython raises an OSError directly
161+ instead. If you use ``except OSError: `` to catch the exception,
162+ your code will work both in MicroPython and CPython.
163+
156164 .. method :: socket.setblocking(flag)
157165
158166 Set blocking or non-blocking mode of the socket: if flag is false, the socket is set to non-blocking,
You can’t perform that action at this time.
0 commit comments