Commit 047af9b1 authored by Damien George's avatar Damien George

cc3200: Remove socket.timeout class, use OSError(ETIMEDOUT) instead.

socket.timeout is a subclass of OSError, and using the latter is more
efficient than having a dedicated class.  The argument of OSError is
ETIMEDOUT so the error can be distinguished from other kinds of
OSErrors.  This follows how the esp8266 port does it.
parent d03f089b
......@@ -520,7 +520,7 @@ STATIC mp_obj_t socket_recv(mp_obj_t self_in, mp_obj_t len_in) {
mp_int_t ret = wlan_socket_recv(self, (byte*)vstr.buf, len, &_errno);
if (ret < 0) {
if (_errno == MP_EAGAIN && self->sock_base.has_timeout) {
mp_raise_msg(&mp_type_TimeoutError, "timed out");
mp_raise_OSError(MP_ETIMEDOUT);
}
mp_raise_OSError(-_errno);
}
......@@ -566,7 +566,7 @@ STATIC mp_obj_t socket_recvfrom(mp_obj_t self_in, mp_obj_t len_in) {
mp_int_t ret = wlan_socket_recvfrom(self, (byte*)vstr.buf, vstr.len, ip, &port, &_errno);
if (ret < 0) {
if (_errno == MP_EAGAIN && self->sock_base.has_timeout) {
mp_raise_msg(&mp_type_TimeoutError, "timed out");
mp_raise_OSError(MP_ETIMEDOUT);
}
mp_raise_OSError(-_errno);
}
......@@ -763,9 +763,6 @@ STATIC const mp_map_elem_t mp_module_usocket_globals_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR_socket), (mp_obj_t)&socket_type },
{ MP_OBJ_NEW_QSTR(MP_QSTR_getaddrinfo), (mp_obj_t)&mod_usocket_getaddrinfo_obj },
// class exceptions
{ MP_OBJ_NEW_QSTR(MP_QSTR_timeout), (mp_obj_t)&mp_type_TimeoutError },
// class constants
{ MP_OBJ_NEW_QSTR(MP_QSTR_AF_INET), MP_OBJ_NEW_SMALL_INT(SL_AF_INET) },
......
......@@ -79,7 +79,6 @@
#define MICROPY_VFS (1)
#define MICROPY_VFS_FAT (1)
#define MICROPY_PY_ASYNC_AWAIT (0)
#define MICROPY_PY_BUILTINS_TIMEOUTERROR (1)
#define MICROPY_PY_ALL_SPECIAL_METHODS (1)
#define MICROPY_PY_BUILTINS_HELP (1)
#define MICROPY_PY_BUILTINS_HELP_TEXT cc3200_help_text
......
Markdown is supported
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