stm32/modusocket: Return OSError(-2) if getaddrinfo fails.
This matches the behaviour of getaddrinfo in extmod/modlwip.c.
This commit is contained in:
parent
5d7b0b237b
commit
0a30ad96c8
|
@ -125,7 +125,7 @@ STATIC int cc3k_gethostbyname(mp_obj_t nic, const char *name, mp_uint_t len, uin
|
||||||
|
|
||||||
if (ip == 0) {
|
if (ip == 0) {
|
||||||
// unknown host
|
// unknown host
|
||||||
return MP_ENOENT;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
out_ip[0] = ip >> 24;
|
out_ip[0] = ip >> 24;
|
||||||
|
|
|
@ -92,7 +92,7 @@ STATIC int wiznet5k_gethostbyname(mp_obj_t nic, const char *name, mp_uint_t len,
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
// failure
|
// failure
|
||||||
return MP_ENOENT;
|
return -2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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) {
|
if (nic_type->gethostbyname != NULL) {
|
||||||
int ret = nic_type->gethostbyname(nic, host, hlen, out_ip);
|
int ret = nic_type->gethostbyname(nic, host, hlen, out_ip);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
// TODO CPython raises: socket.gaierror: [Errno -2] Name or service not known
|
|
||||||
mp_raise_OSError(ret);
|
mp_raise_OSError(ret);
|
||||||
}
|
}
|
||||||
have_ip = true;
|
have_ip = true;
|
||||||
|
|
Loading…
Reference in New Issue