Skip to content

Commit 2831a8f

Browse files
committed
modsocket: .recv() returns bytes object.
1 parent 4ef26c1 commit 2831a8f

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

unix/modsocket.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#include "obj.h"
4646
#include "objtuple.h"
4747
#include "objarray.h"
48+
#include "objstr.h"
4849
#include "runtime.h"
4950
#include "stream.h"
5051
#include "builtin.h"
@@ -179,11 +180,11 @@ STATIC mp_obj_t socket_recv(uint n_args, const mp_obj_t *args) {
179180
flags = MP_OBJ_SMALL_INT_VALUE(args[2]);
180181
}
181182

182-
char *buf = m_new(char, sz);
183+
byte *buf = m_new(byte, sz);
183184
int out_sz = recv(self->fd, buf, sz, flags);
184185
RAISE_ERRNO(out_sz, errno);
185186

186-
mp_obj_t ret = MP_OBJ_NEW_QSTR(qstr_from_strn(buf, out_sz));
187+
mp_obj_t ret = mp_obj_new_str_of_type(&mp_type_bytes, buf, out_sz);
187188
m_del(char, buf, sz);
188189
return ret;
189190
}

0 commit comments

Comments
 (0)