Commit 59540dcc authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

docs/usocket: Clarify exceptions used.

parent 0aa83142
......@@ -10,6 +10,12 @@ This module provides access to the BSD socket interface.
See corresponding `CPython module <>`_ for
.. admonition:: Difference to CPython
:class: attention
CPython used to have a ``socket.error`` exception which is now deprecated,
and is an alias of OSError. In MicroPython, use OSError directly.
Socket address format(s)
......@@ -51,13 +57,18 @@ Functions
s = socket.socket()
s.connect(socket.getaddrinfo('', 80)[0][-1])
.. only:: port_wipy
.. data:: socket.error
.. data:: socket.timeout
.. admonition:: Difference to CPython
:class: attention
CPython raises a ``socket.gaierror`` exception (OSError subclass) in case
of error in this function. MicroPython doesn't have ``socket.gaierror``
and raises OSError directly. Note that error numbers of ``getaddrinfo()``
form a separate namespace and may not match error numbers from
``uerrno`` module. To distinguish ``getaddrinfo()`` errors, they are
represented by negative numbers, whereas standard system errors are
positive numbers (error numbers are accessible using ``e.args[0]`` property
from an exception object). The use of negative values is a provisional
detail which may change in the future.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment