Skip to content
Snippets Groups Projects
Commit 12a9cfed authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

modsocket: Make .send() support arbitrary objects with buffer interface.

This is CPython-compliant (except that CPython doesn't support buffer
protocol for str).
parent 45fb143b
No related branches found
No related tags found
No related merge requests found
......@@ -148,9 +148,9 @@ STATIC mp_obj_t socket_send(uint n_args, const mp_obj_t *args) {
flags = MP_OBJ_SMALL_INT_VALUE(args[2]);
}
uint sz;
const char *buf = mp_obj_str_get_data(args[1], &sz);
int out_sz = send(self->fd, buf, sz, flags);
mp_buffer_info_t bufinfo;
mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_READ);
int out_sz = send(self->fd, bufinfo.buf, bufinfo.len, flags);
RAISE_ERRNO(out_sz, errno);
return MP_OBJ_NEW_SMALL_INT((machine_int_t)out_sz);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment