stm32/modusocket: Return OSError(-2) if getaddrinfo fails.

This matches the behaviour of getaddrinfo in extmod/modlwip.c.
This commit is contained in:
Damien George 2017-10-16 13:19:11 +11:00
parent 5d7b0b237b
commit 0a30ad96c8
3 changed files with 2 additions and 3 deletions

View File

@ -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;

View File

@ -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;
}
}

View File

@ -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;