diff --git a/ports/unix/modos.c b/ports/unix/modos.c index deea3bfc91..6bed69c43a 100644 --- a/ports/unix/modos.c +++ b/ports/unix/modos.c @@ -56,6 +56,10 @@ #endif #endif +#if defined(MICROPY_UNIX_COVERAGE) +mp_obj_t common_hal_os_getenv(const char *key, mp_obj_t default_); +#endif + STATIC mp_obj_t mod_os_urandom(mp_obj_t num) { mp_int_t n = mp_obj_get_int(num); vstr_t vstr; @@ -193,12 +197,13 @@ STATIC mp_obj_t mod_os_system(mp_obj_t cmd_in) { } MP_DEFINE_CONST_FUN_OBJ_1(mod_os_system_obj, mod_os_system); -mp_obj_t common_hal_os_getenv(const char *key, mp_obj_t default_); STATIC mp_obj_t mod_os_getenv(mp_obj_t var_in) { + #if defined(MICROPY_UNIX_COVERAGE) mp_obj_t result = common_hal_os_getenv(mp_obj_str_get_str(var_in), mp_const_none); if (result != mp_const_none) { return result; } + #endif const char *s = getenv(mp_obj_str_get_str(var_in)); if (s == NULL) { return mp_const_none;