summaryrefslogtreecommitdiffstatshomepage
path: root/py/objstr.c
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-01-13 19:19:16 +0200
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-01-15 02:15:38 +0200
commit76d982ef343dcadd35355aed9c568984c850fb7b (patch)
tree1ded5f199ce740d3b72c00cc1e9c2b402936632f /py/objstr.c
parent24224d7c72e1d6572ef0d24f08eb882dcac8dc50 (diff)
downloadmicropython-76d982ef343dcadd35355aed9c568984c850fb7b.tar.gz
micropython-76d982ef343dcadd35355aed9c568984c850fb7b.zip
type->print(): Distinguish str() and repr() variety by passing extra param.
Diffstat (limited to 'py/objstr.c')
-rw-r--r--py/objstr.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/py/objstr.c b/py/objstr.c
index 8b7ab9692f..81fd952915 100644
--- a/py/objstr.c
+++ b/py/objstr.c
@@ -22,10 +22,14 @@ static mp_obj_t mp_obj_new_str_iterator(mp_obj_str_t *str, int cur);
/******************************************************************************/
/* str */
-void str_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in) {
+void str_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
mp_obj_str_t *self = self_in;
- // TODO need to escape chars etc
- print(env, "'%s'", qstr_str(self->qstr));
+ if (kind == PRINT_STR) {
+ print(env, "%s", qstr_str(self->qstr));
+ } else {
+ // TODO need to escape chars etc
+ print(env, "'%s'", qstr_str(self->qstr));
+ }
}
mp_obj_t str_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
@@ -277,7 +281,8 @@ mp_obj_t str_format(int n_args, const mp_obj_t *args) {
if (arg_i >= n_args) {
nlr_jump(mp_obj_new_exception_msg(MP_QSTR_IndexError, "tuple index out of range"));
}
- mp_obj_print_helper(vstr_printf_wrapper, vstr, args[arg_i]);
+ // TODO: may be PRINT_REPR depending on formatting code
+ mp_obj_print_helper(vstr_printf_wrapper, vstr, args[arg_i], PRINT_STR);
arg_i++;
}
} else {