From ce89a21ea49e51274d016d9601c462312664271e Mon Sep 17 00:00:00 2001 From: Damien Date: Tue, 15 Oct 2013 22:25:17 +0100 Subject: Implement basic exception framework, and simple for loop. --- unix/main.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'unix/main.c') diff --git a/unix/main.c b/unix/main.c index eb120da01..8ceaf4264 100644 --- a/unix/main.c +++ b/unix/main.c @@ -2,6 +2,7 @@ #include #include +#include "nlr.h" #include "misc.h" #include "mpyconfig.h" #include "lexer.h" @@ -47,10 +48,19 @@ int main(int argc, char **argv) { // execute it py_obj_t module_fun = rt_make_function_from_id(1); if (module_fun != py_const_none) { - py_obj_t ret = rt_call_function_0(module_fun); - printf("done! got: "); - py_obj_print(ret); - printf("\n"); + nlr_buf_t nlr; + if (nlr_push(&nlr) == 0) { + py_obj_t ret = rt_call_function_0(module_fun); + printf("done! got: "); + py_obj_print(ret); + printf("\n"); + nlr_pop(); + } else { + // uncaught exception + printf("exception: "); + py_obj_print((py_obj_t)nlr.ret_val); + printf("\n"); + } } } #endif -- cgit v1.2.3