Skip to content

Commit fa6f050

Browse files
committed
unix: Workaround MP_OBJ_NEW_SMALL_INT() 64-bit issues.
1 parent 5d3a830 commit fa6f050

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

unix/file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ STATIC mp_obj_t fdfile_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const
106106

107107
int fd = open(fname, mode, 0644);
108108
if (fd == -1) {
109-
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(errno)));
109+
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT((machine_int_t)errno)));
110110
}
111111
return fdfile_new(fd);
112112
}

unix/modffi.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ STATIC mp_obj_t ffimod_func(uint n_args, const mp_obj_t *args) {
145145

146146
void *sym = dlsym(self->handle, symname);
147147
if (sym == NULL) {
148-
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(errno)));
148+
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT((machine_int_t)errno)));
149149
}
150150
int nparams = MP_OBJ_SMALL_INT_VALUE(mp_obj_len_maybe(args[3]));
151151
mp_obj_ffifunc_t *o = m_new_obj_var(mp_obj_ffifunc_t, ffi_type*, nparams);
@@ -219,7 +219,7 @@ STATIC mp_obj_t ffimod_var(mp_obj_t self_in, mp_obj_t vartype_in, mp_obj_t symna
219219

220220
void *sym = dlsym(self->handle, symname);
221221
if (sym == NULL) {
222-
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(errno)));
222+
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT((machine_int_t)errno)));
223223
}
224224
mp_obj_ffivar_t *o = m_new_obj(mp_obj_ffivar_t);
225225
o->base.type = &ffivar_type;
@@ -235,7 +235,7 @@ STATIC mp_obj_t ffimod_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const
235235
void *mod = dlopen(fname, RTLD_NOW | RTLD_LOCAL);
236236

237237
if (mod == NULL) {
238-
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(errno)));
238+
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT((machine_int_t)errno)));
239239
}
240240
mp_obj_ffimod_t *o = m_new_obj(mp_obj_ffimod_t);
241241
o->base.type = type_in;

unix/modsocket.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ STATIC const mp_obj_type_t microsocket_type;
3333
// Helper functions
3434
#define RAISE_ERRNO(err_flag, error_val) \
3535
{ if (err_flag == -1) \
36-
{ nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(error_val))); } }
36+
{ nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT((machine_int_t)error_val))); } }
3737

3838
STATIC mp_obj_socket_t *socket_new(int fd) {
3939
mp_obj_socket_t *o = m_new_obj(mp_obj_socket_t);
@@ -283,7 +283,7 @@ STATIC mp_obj_t mod_socket_gethostbyname(mp_obj_t arg) {
283283
struct hostent *h = gethostbyname(s);
284284
if (h == NULL) {
285285
// CPython: socket.herror
286-
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(h_errno)));
286+
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT((machine_int_t)h_errno)));
287287
}
288288
assert(h->h_length == 4);
289289
return mp_obj_new_int(*(int*)*h->h_addr_list);

0 commit comments

Comments
 (0)