cc3200: Make socket.listen([backlog]) compliant with Python 3.5.
This commit is contained in:
parent
719dca2515
commit
4b630c452d
|
@ -185,17 +185,23 @@ STATIC mp_obj_t socket_bind(mp_obj_t self_in, mp_obj_t addr_in) {
|
||||||
}
|
}
|
||||||
STATIC MP_DEFINE_CONST_FUN_OBJ_2(socket_bind_obj, socket_bind);
|
STATIC MP_DEFINE_CONST_FUN_OBJ_2(socket_bind_obj, socket_bind);
|
||||||
|
|
||||||
// method socket.listen(backlog)
|
// method socket.listen([backlog])
|
||||||
STATIC mp_obj_t socket_listen(mp_obj_t self_in, mp_obj_t backlog) {
|
STATIC mp_obj_t socket_listen(mp_uint_t n_args, const mp_obj_t *args) {
|
||||||
mod_network_socket_obj_t *self = self_in;
|
mod_network_socket_obj_t *self = args[0];
|
||||||
|
|
||||||
|
int32_t backlog = 0;
|
||||||
|
if (n_args > 1) {
|
||||||
|
backlog = mp_obj_get_int(args[1]);
|
||||||
|
backlog = (backlog < 0) ? 0 : backlog;
|
||||||
|
}
|
||||||
|
|
||||||
int _errno;
|
int _errno;
|
||||||
if (wlan_socket_listen(self, mp_obj_get_int(backlog), &_errno) != 0) {
|
if (wlan_socket_listen(self, backlog, &_errno) != 0) {
|
||||||
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(-_errno)));
|
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(-_errno)));
|
||||||
}
|
}
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
STATIC MP_DEFINE_CONST_FUN_OBJ_2(socket_listen_obj, socket_listen);
|
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(socket_listen_obj, 1, 2, socket_listen);
|
||||||
|
|
||||||
// method socket.accept()
|
// method socket.accept()
|
||||||
STATIC mp_obj_t socket_accept(mp_obj_t self_in) {
|
STATIC mp_obj_t socket_accept(mp_obj_t self_in) {
|
||||||
|
|
Loading…
Reference in New Issue