diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-04-26 05:53:02 +0300 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-04-26 05:54:22 +0300 |
commit | 12a9cfed7693a3e2495e619ec90c922c6ecb0908 (patch) | |
tree | 073c1b1b73c288ae29c57fa102cf62f94e7fd875 | |
parent | 45fb143ba62b70fc25264401f86ed79494d73ff9 (diff) | |
download | micropython-12a9cfed7693a3e2495e619ec90c922c6ecb0908.tar.gz micropython-12a9cfed7693a3e2495e619ec90c922c6ecb0908.zip |
modsocket: Make .send() support arbitrary objects with buffer interface.
This is CPython-compliant (except that CPython doesn't support buffer
protocol for str).
-rw-r--r-- | unix/modsocket.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/unix/modsocket.c b/unix/modsocket.c index b7d167c8ad..4c76502da6 100644 --- a/unix/modsocket.c +++ b/unix/modsocket.c @@ -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); |