diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-08-10 21:20:40 +0300 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-08-10 21:24:47 +0300 |
commit | 2831a8f8007fc04feb00d9f2970c8e54470ec8c2 (patch) | |
tree | 16de482baec501d057329ffd1921f29e1ae1e7e8 /unix | |
parent | 4ef26c14b1182da7075b65b995e7da7b0a94961d (diff) | |
download | micropython-2831a8f8007fc04feb00d9f2970c8e54470ec8c2.tar.gz micropython-2831a8f8007fc04feb00d9f2970c8e54470ec8c2.zip |
modsocket: .recv() returns bytes object.
Diffstat (limited to 'unix')
-rw-r--r-- | unix/modsocket.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/unix/modsocket.c b/unix/modsocket.c index d5b8e11c24..7eae1d8bf9 100644 --- a/unix/modsocket.c +++ b/unix/modsocket.c @@ -45,6 +45,7 @@ #include "obj.h" #include "objtuple.h" #include "objarray.h" +#include "objstr.h" #include "runtime.h" #include "stream.h" #include "builtin.h" @@ -179,11 +180,11 @@ STATIC mp_obj_t socket_recv(uint n_args, const mp_obj_t *args) { flags = MP_OBJ_SMALL_INT_VALUE(args[2]); } - char *buf = m_new(char, sz); + byte *buf = m_new(byte, sz); int out_sz = recv(self->fd, buf, sz, flags); RAISE_ERRNO(out_sz, errno); - mp_obj_t ret = MP_OBJ_NEW_QSTR(qstr_from_strn(buf, out_sz)); + mp_obj_t ret = mp_obj_new_str_of_type(&mp_type_bytes, buf, out_sz); m_del(char, buf, sz); return ret; } |