From 88343302ae5f980c41ec7a4d498af63e7c1dbb52 Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 14 Jan 2026 12:25:40 +1100 Subject: [PATCH] nrf/mpconfigport: Remove duplicate help and open from builtins module. The `builtins.help` function is automatically included when `MICROPY_PY_BUILTINS_HELP` is enabled, which is true for this port. The `builtins.open` function is automatically included when `MICROPY_PY_IO` is enabled, which is true when `MICROPY_VFS` is enabled on this port. If `MICROPY_MBFS` is enabled instead of the VFS then `open` must be explicitly provided. Tested on: - ARDUINO_NANO_33_BLE_SENSE: now has only a single `help` and `open` - MICROBIT: now has only a single `help` and `open` - MICROBIT with MICROPY_MBFS enabled: `help` and `open` both still exist and `open` works with mbfs Signed-off-by: Damien George --- ports/nrf/main.c | 5 ----- ports/nrf/mpconfigport.h | 7 ++++--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/ports/nrf/main.c b/ports/nrf/main.c index 1013005e19..bb3bcec36d 100644 --- a/ports/nrf/main.c +++ b/ports/nrf/main.c @@ -312,11 +312,6 @@ mp_lexer_t *mp_lexer_new_from_file(qstr filename) { mp_import_stat_t mp_import_stat(const char *path) { return MP_IMPORT_STAT_NO_EXIST; } - -mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) { - mp_raise_OSError(MP_EPERM); -} -MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_open_obj, 1, mp_builtin_open); #endif #endif diff --git a/ports/nrf/mpconfigport.h b/ports/nrf/mpconfigport.h index 80e37bc4f7..cad839d0e9 100644 --- a/ports/nrf/mpconfigport.h +++ b/ports/nrf/mpconfigport.h @@ -353,10 +353,11 @@ long unsigned int rng_generate_random_word(void); #include "boardmodules.h" #endif // BOARD_SPECIFIC_MODULES -// extra built in names to add to the global namespace +#if MICROPY_MBFS +// The builtins.open function must be explicitly added when using the micro:bit filesystem. #define MICROPY_PORT_BUILTINS \ - { MP_ROM_QSTR(MP_QSTR_help), MP_ROM_PTR(&mp_builtin_help_obj) }, \ - { MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&mp_builtin_open_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&mp_builtin_open_obj) }, +#endif // extra constants #define MICROPY_PORT_CONSTANTS \