From 0a30ad96c886aacf897b3e87cbdb24fb46c5c43d Mon Sep 17 00:00:00 2001 From: Damien George Date: Mon, 16 Oct 2017 13:19:11 +1100 Subject: [PATCH] stm32/modusocket: Return OSError(-2) if getaddrinfo fails. This matches the behaviour of getaddrinfo in extmod/modlwip.c. --- ports/stm32/modnwcc3k.c | 2 +- ports/stm32/modnwwiznet5k.c | 2 +- ports/stm32/modusocket.c | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/ports/stm32/modnwcc3k.c b/ports/stm32/modnwcc3k.c index 551206da8e..8cc0a613d1 100644 --- a/ports/stm32/modnwcc3k.c +++ b/ports/stm32/modnwcc3k.c @@ -125,7 +125,7 @@ STATIC int cc3k_gethostbyname(mp_obj_t nic, const char *name, mp_uint_t len, uin if (ip == 0) { // unknown host - return MP_ENOENT; + return -2; } out_ip[0] = ip >> 24; diff --git a/ports/stm32/modnwwiznet5k.c b/ports/stm32/modnwwiznet5k.c index a9e5f5aa91..9e9fb9aea6 100644 --- a/ports/stm32/modnwwiznet5k.c +++ b/ports/stm32/modnwwiznet5k.c @@ -92,7 +92,7 @@ STATIC int wiznet5k_gethostbyname(mp_obj_t nic, const char *name, mp_uint_t len, return 0; } else { // failure - return MP_ENOENT; + return -2; } } diff --git a/ports/stm32/modusocket.c b/ports/stm32/modusocket.c index 4d14c355f6..71a237b0d9 100644 --- a/ports/stm32/modusocket.c +++ b/ports/stm32/modusocket.c @@ -413,7 +413,6 @@ STATIC mp_obj_t mod_usocket_getaddrinfo(mp_obj_t host_in, mp_obj_t port_in) { if (nic_type->gethostbyname != NULL) { int ret = nic_type->gethostbyname(nic, host, hlen, out_ip); if (ret != 0) { - // TODO CPython raises: socket.gaierror: [Errno -2] Name or service not known mp_raise_OSError(ret); } have_ip = true;