diff --git a/components/micropython/vendor/py/objdict.c b/components/micropython/vendor/py/objdict.c index efcd617dad8e7193b433a3ba9bf11699a280704d..60380963a4dafe2bc8e6d4e0867e473ed9203f7d 100644 --- a/components/micropython/vendor/py/objdict.c +++ b/components/micropython/vendor/py/objdict.c @@ -95,7 +95,9 @@ STATIC void dict_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_ mp_print_str(print, "{"); size_t cur = 0; mp_map_elem_t *next = NULL; - MP_PRINT_GET_EXT(print)->indent_depth++; + if(kind == PRINT_JSON){ + MP_PRINT_GET_EXT(print)->indent_depth++; + } while ((next = dict_iter_next(self, &cur)) != NULL) { if (!first) { mp_print_str(print, item_separator); @@ -113,7 +115,9 @@ STATIC void dict_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_ mp_print_str(print, key_separator); mp_obj_print_helper(print, next->value, kind); } - MP_PRINT_GET_EXT(print)->indent_depth--; + if(kind == PRINT_JSON){ + MP_PRINT_GET_EXT(print)->indent_depth--; + } mp_print_indent(print, indent_str); mp_print_str(print, "}"); if (MICROPY_PY_COLLECTIONS_ORDEREDDICT && self->base.type != &mp_type_dict && kind != PRINT_JSON) { diff --git a/components/micropython/vendor/py/objlist.c b/components/micropython/vendor/py/objlist.c index d9811724fca3b5829d0c35b6e17db78b51075ef3..333d3bd2a3c5a87dd628ef87176d70ef07206e5a 100644 --- a/components/micropython/vendor/py/objlist.c +++ b/components/micropython/vendor/py/objlist.c @@ -58,7 +58,9 @@ STATIC void list_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t k } mp_print_str(print, "["); - MP_PRINT_GET_EXT(print)->indent_depth++; + if(kind == PRINT_JSON){ + MP_PRINT_GET_EXT(print)->indent_depth++; + } for (size_t i = 0; i < o->len; i++) { if (i > 0) { mp_print_str(print, item_separator); @@ -66,7 +68,9 @@ STATIC void list_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t k mp_print_indent(print, indent_str); mp_obj_print_helper(print, o->items[i], kind); } - MP_PRINT_GET_EXT(print)->indent_depth--; + if(kind == PRINT_JSON){ + MP_PRINT_GET_EXT(print)->indent_depth--; + } mp_print_indent(print, indent_str); mp_print_str(print, "]"); } diff --git a/components/micropython/vendor/py/objtuple.c b/components/micropython/vendor/py/objtuple.c index 6fe7f2d0abfaa63ee81f951bfa548a104b2508f8..6b402ce71c05938a2efbd939536aeebeb858041a 100644 --- a/components/micropython/vendor/py/objtuple.c +++ b/components/micropython/vendor/py/objtuple.c @@ -54,7 +54,9 @@ void mp_obj_tuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t if(kind == PRINT_JSON){ indent_str = MP_PRINT_GET_EXT(print)->indent; } - MP_PRINT_GET_EXT(print)->indent_depth++; + if(kind == PRINT_JSON){ + MP_PRINT_GET_EXT(print)->indent_depth++; + } for (size_t i = 0; i < o->len; i++) { if (i > 0) { mp_print_str(print, item_separator); @@ -62,7 +64,9 @@ void mp_obj_tuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t mp_print_indent(print, indent_str); mp_obj_print_helper(print, o->items[i], kind); } - MP_PRINT_GET_EXT(print)->indent_depth--; + if(kind == PRINT_JSON){ + MP_PRINT_GET_EXT(print)->indent_depth--; + } mp_print_indent(print, indent_str); if (MICROPY_PY_UJSON && kind == PRINT_JSON) { mp_print_str(print, "]");