Commit 4899ff94 authored by Damien George's avatar Damien George
Browse files

Merge branch 'str-repr' of github.com:pfalcon/micropython into pfalcon-str-repr

Conflicts:
	tests/basics/tests/exception1.py
parents 7a9d0c45 36c4499d
......@@ -4,4 +4,4 @@ typedef struct _mp_obj_tuple_t {
mp_obj_t items[];
} mp_obj_tuple_t;
void tuple_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in);
void tuple_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in, mp_print_kind_t kind);
......@@ -66,7 +66,7 @@ static mp_map_elem_t *mp_obj_class_lookup(const mp_obj_type_t *type, qstr attr,
}
}
static void class_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in) {
static void class_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
print(env, "<%s object at %p>", mp_obj_get_type_str(self_in), self_in);
}
......@@ -148,7 +148,7 @@ static bool class_store_attr(mp_obj_t self_in, qstr attr, mp_obj_t value) {
// - there is a constant mp_obj_type_t (called mp_const_type) for the 'type' object
// - creating a new class (a new type) creates a new mp_obj_type_t
static void type_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in) {
static void type_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
mp_obj_type_t *self = self_in;
print(env, "<class '%s'>", self->name);
}
......
......@@ -141,6 +141,7 @@ void rt_init(void) {
mp_map_add_qstr(&map_builtins, MP_QSTR_repr, (mp_obj_t)&mp_builtin_repr_obj);
mp_map_add_qstr(&map_builtins, MP_QSTR_sorted, (mp_obj_t)&mp_builtin_sorted_obj);
mp_map_add_qstr(&map_builtins, MP_QSTR_sum, (mp_obj_t)&mp_builtin_sum_obj);
mp_map_add_qstr(&map_builtins, MP_QSTR_str, (mp_obj_t)&mp_builtin_str_obj);
next_unique_code_id = 1; // 0 indicates "no code"
unique_codes_alloc = 0;
......
......@@ -444,7 +444,7 @@ void do_repl(void) {
}
} else {
// uncaught exception
mp_obj_print((mp_obj_t)nlr.ret_val);
mp_obj_print((mp_obj_t)nlr.ret_val, PRINT_REPR);
printf("\n");
}
}
......@@ -489,7 +489,7 @@ bool do_file(const char *filename) {
return true;
} else {
// uncaught exception
mp_obj_print((mp_obj_t)nlr.ret_val);
mp_obj_print((mp_obj_t)nlr.ret_val, PRINT_REPR);
printf("\n");
return false;
}
......@@ -671,7 +671,7 @@ typedef struct _pyb_file_obj_t {
FIL fp;
} pyb_file_obj_t;
void file_obj_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in) {
void file_obj_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
printf("<file %p>", self_in);
}
......@@ -1114,13 +1114,13 @@ soft_reset:
if (nlr_push(&nlr) == 0) {
mp_obj_t ret = rt_call_function_0(module_fun);
printf("done! got: ");
mp_obj_print(ret);
mp_obj_print(ret, PRINT_REPR);
printf("\n");
nlr_pop();
} else {
// uncaught exception
printf("exception: ");
mp_obj_print((mp_obj_t)nlr.ret_val);
mp_obj_print((mp_obj_t)nlr.ret_val, PRINT_REPR);
printf("\n");
}
......
......@@ -89,7 +89,7 @@ void timer_interrupt(void) {
} else {
// uncaught exception
printf("exception in timer interrupt\n");
mp_obj_print((mp_obj_t)nlr.ret_val);
mp_obj_print((mp_obj_t)nlr.ret_val, PRINT_REPR);
printf("\n");
}
}
......
print(repr(IndexError()))
print(str(IndexError()))
print(repr(IndexError("foo")))
print(str(IndexError("foo")))
a = IndexError(1, "test", [100, 200])
print(repr(a))
print(str(a))
......@@ -15,7 +15,7 @@ typedef struct _mp_obj_fdfile_t {
int fd;
} mp_obj_fdfile_t;
static void fdfile_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in) {
static void fdfile_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
mp_obj_fdfile_t *self = self_in;
print(env, "<io.FileIO %d>", self->fd);
}
......
......@@ -69,7 +69,7 @@ static void execute_from_lexer(mp_lexer_t *lex, mp_parse_input_kind_t input_kind
nlr_pop();
} else {
// uncaught exception
mp_obj_print((mp_obj_t)nlr.ret_val);
mp_obj_print((mp_obj_t)nlr.ret_val, PRINT_REPR);
printf("\n");
}
}
......@@ -165,7 +165,7 @@ typedef struct _test_obj_t {
int value;
} test_obj_t;
static void test_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in) {
static void test_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
test_obj_t *self = self_in;
print(env, "<test %d>", self->value);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment