Skip to content

Commit 696eee9

Browse files
committed
modffi: dlsym() doesn't set errno, so use ENOENT for OSError.
This may be a bit confusing, as ENOENT is often rendered as "No such file or directory", but any other code would be only more confusing.
1 parent a9058bf commit 696eee9

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

unix/modffi.c

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

215215
void *sym = dlsym(self->handle, symname);
216216
if (sym == NULL) {
217-
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(errno)));
217+
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(ENOENT)));
218218
}
219219
return make_func(args[1], sym, args[3]);
220220
}
@@ -277,7 +277,7 @@ STATIC mp_obj_t ffimod_var(mp_obj_t self_in, mp_obj_t vartype_in, mp_obj_t symna
277277

278278
void *sym = dlsym(self->handle, symname);
279279
if (sym == NULL) {
280-
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(errno)));
280+
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(ENOENT)));
281281
}
282282
mp_obj_ffivar_t *o = m_new_obj(mp_obj_ffivar_t);
283283
o->base.type = &ffivar_type;
@@ -294,7 +294,7 @@ STATIC mp_obj_t ffimod_addr(mp_obj_t self_in, mp_obj_t symname_in) {
294294

295295
void *sym = dlsym(self->handle, symname);
296296
if (sym == NULL) {
297-
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(errno)));
297+
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(ENOENT)));
298298
}
299299
return mp_obj_new_int((mp_int_t)sym);
300300
}

0 commit comments

Comments
 (0)