summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorTom Collins <tom.collins@digi.com>2017-01-12 16:08:51 -0800
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2017-05-14 18:24:50 +0300
commitf06d0839bdaff783d8902bcedb572cbaabb6447a (patch)
tree7087cd53e9b36b3f52b35f497eef5e110d7e7e9b
parent55491031be1f267e07b2495916d4f5ba2735cc00 (diff)
downloadmicropython-f06d0839bdaff783d8902bcedb572cbaabb6447a.tar.gz
micropython-f06d0839bdaff783d8902bcedb572cbaabb6447a.zip
py/modsys: update conditionals for code referencing sys.stdout
Working on a build with PY_IO enabled (for PY_UJSON support) but PY_SYS_STDFILES disabled (no filesystem). There are multiple references to mp_sys_stdout_obj that should only be enabled if both PY_IO and PY_SYS_STDFILES are enabled.
-rw-r--r--py/modbuiltins.c8
-rw-r--r--py/modsys.c4
-rw-r--r--py/mpprint.h4
3 files changed, 8 insertions, 8 deletions
diff --git a/py/modbuiltins.c b/py/modbuiltins.c
index e8119456db..17bd30c521 100644
--- a/py/modbuiltins.c
+++ b/py/modbuiltins.c
@@ -406,7 +406,7 @@ STATIC mp_obj_t mp_builtin_print(size_t n_args, const mp_obj_t *args, mp_map_t *
if (end_elem != NULL && end_elem->value != mp_const_none) {
end_data = mp_obj_str_get_data(end_elem->value, &end_len);
}
- #if MICROPY_PY_IO
+ #if MICROPY_PY_IO && MICROPY_PY_SYS_STDFILES
void *stream_obj = &mp_sys_stdout_obj;
mp_map_elem_t *file_elem = mp_map_lookup(kwargs, MP_OBJ_NEW_QSTR(MP_QSTR_file), MP_MAP_LOOKUP);
if (file_elem != NULL && file_elem->value != mp_const_none) {
@@ -417,19 +417,19 @@ STATIC mp_obj_t mp_builtin_print(size_t n_args, const mp_obj_t *args, mp_map_t *
#endif
for (mp_uint_t i = 0; i < n_args; i++) {
if (i > 0) {
- #if MICROPY_PY_IO
+ #if MICROPY_PY_IO && MICROPY_PY_SYS_STDFILES
mp_stream_write_adaptor(stream_obj, sep_data, sep_len);
#else
mp_print_strn(&mp_plat_print, sep_data, sep_len, 0, 0, 0);
#endif
}
- #if MICROPY_PY_IO
+ #if MICROPY_PY_IO && MICROPY_PY_SYS_STDFILES
mp_obj_print_helper(&print, args[i], PRINT_STR);
#else
mp_obj_print_helper(&mp_plat_print, args[i], PRINT_STR);
#endif
}
- #if MICROPY_PY_IO
+ #if MICROPY_PY_IO && MICROPY_PY_SYS_STDFILES
mp_stream_write_adaptor(stream_obj, end_data, end_len);
#else
mp_print_strn(&mp_plat_print, end_data, end_len, 0, 0, 0);
diff --git a/py/modsys.c b/py/modsys.c
index b208c88bd6..5fbcb944c4 100644
--- a/py/modsys.c
+++ b/py/modsys.c
@@ -45,7 +45,7 @@ extern struct _mp_dummy_t mp_sys_stdin_obj;
extern struct _mp_dummy_t mp_sys_stdout_obj;
extern struct _mp_dummy_t mp_sys_stderr_obj;
-#if MICROPY_PY_IO
+#if MICROPY_PY_IO && MICROPY_PY_SYS_STDFILES
const mp_print_t mp_sys_stdout_print = {&mp_sys_stdout_obj, mp_stream_write_adaptor};
#endif
@@ -106,7 +106,7 @@ STATIC mp_obj_t mp_sys_exit(size_t n_args, const mp_obj_t *args) {
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_sys_exit_obj, 0, 1, mp_sys_exit);
STATIC mp_obj_t mp_sys_print_exception(size_t n_args, const mp_obj_t *args) {
- #if MICROPY_PY_IO
+ #if MICROPY_PY_IO && MICROPY_PY_SYS_STDFILES
void *stream_obj = &mp_sys_stdout_obj;
if (n_args > 1) {
stream_obj = MP_OBJ_TO_PTR(args[1]); // XXX may fail
diff --git a/py/mpprint.h b/py/mpprint.h
index f9204e322d..4fc904a20a 100644
--- a/py/mpprint.h
+++ b/py/mpprint.h
@@ -39,7 +39,7 @@
#define PF_FLAG_ADD_PERCENT (0x100)
#define PF_FLAG_SHOW_OCTAL_LETTER (0x200)
-#if MICROPY_PY_IO
+#if MICROPY_PY_IO && MICROPY_PY_SYS_STDFILES
# define MP_PYTHON_PRINTER &mp_sys_stdout_print
#else
# define MP_PYTHON_PRINTER &mp_plat_print
@@ -55,7 +55,7 @@ typedef struct _mp_print_t {
// All (non-debug) prints go through one of the two interfaces below.
// 1) Wrapper for platform print function, which wraps MP_PLAT_PRINT_STRN.
extern const mp_print_t mp_plat_print;
-#if MICROPY_PY_IO
+#if MICROPY_PY_IO && MICROPY_PY_SYS_STDFILES
// 2) Wrapper for printing to sys.stdout.
extern const mp_print_t mp_sys_stdout_print;
#endif