Skip to content

Commit 4165cd1

Browse files
committed
stmhal: Update for static mod sys.
1 parent a3e50ea commit 4165cd1

4 files changed

Lines changed: 10 additions & 4 deletions

File tree

py/modsys.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ STATIC const mp_map_elem_t mp_module_sys_globals_table[] = {
2323
{ MP_OBJ_NEW_QSTR(MP_QSTR_path), (mp_obj_t)&mp_sys_path_obj },
2424
{ MP_OBJ_NEW_QSTR(MP_QSTR_argv), (mp_obj_t)&mp_sys_argv_obj },
2525

26+
#if MICROPY_MOD_SYS_STDFILES
2627
{ MP_OBJ_NEW_QSTR(MP_QSTR_stdin), (mp_obj_t)&mp_sys_stdin_obj },
2728
{ MP_OBJ_NEW_QSTR(MP_QSTR_stdout), (mp_obj_t)&mp_sys_stdout_obj },
2829
{ MP_OBJ_NEW_QSTR(MP_QSTR_stderr), (mp_obj_t)&mp_sys_stderr_obj },
30+
#endif
2931
};
3032

3133
STATIC const mp_obj_dict_t mp_module_sys_globals = {

py/mpconfig.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ typedef double mp_float_t;
125125
#define MICROPY_ENABLE_MOD_SYS (1)
126126
#endif
127127

128+
#ifndef MICROPY_MOD_SYS_STDFILES
129+
#define MICROPY_MOD_SYS_STDFILES (0)
130+
#endif
131+
128132
// Whether to support slice object and correspondingly
129133
// slice subscript operators
130134
#ifndef MICROPY_ENABLE_SLICE

stmhal/main.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,9 @@ int main(void) {
263263
// Micro Python init
264264
qstr_init();
265265
mp_init();
266-
mp_obj_t def_path[2];
267-
def_path[0] = MP_OBJ_NEW_QSTR(MP_QSTR_0_colon__slash_);
268-
def_path[1] = MP_OBJ_NEW_QSTR(MP_QSTR_0_colon__slash_lib);
269-
mp_sys_path = mp_obj_new_list(2, def_path);
266+
mp_obj_list_init(mp_sys_path, 0);
267+
mp_obj_list_append(mp_sys_argv, MP_OBJ_NEW_QSTR(MP_QSTR_0_colon__slash_));
268+
mp_obj_list_append(mp_sys_argv, MP_OBJ_NEW_QSTR(MP_QSTR_0_colon__slash_lib));
270269

271270
readline_init();
272271

unix/mpconfigport.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_DOUBLE)
1414
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ)
1515
#define MICROPY_PATH_MAX (PATH_MAX)
16+
#define MICROPY_MOD_SYS_STDFILES (1)
1617

1718
// type definitions for the specific machine
1819

0 commit comments

Comments
 (0)