summaryrefslogtreecommitdiffstatshomepage
path: root/unix
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-08-16 14:32:06 +0100
committerDamien George <damien.p.george@gmail.com>2014-08-16 14:32:06 +0100
commit8f81b5cb4bebf6aeaecf3f19a92be288f633c542 (patch)
treecdbef6f235845383e5a21cf9fb9f062f7fd1adf6 /unix
parentb63be37be171dd9a88912e848a380fe035711d99 (diff)
downloadmicropython-8f81b5cb4bebf6aeaecf3f19a92be288f633c542.tar.gz
micropython-8f81b5cb4bebf6aeaecf3f19a92be288f633c542.zip
py: Put SystemExit in builtin namespace.
Also fix unix port so that SystemExit with no arg exits with value 0.
Diffstat (limited to 'unix')
-rw-r--r--unix/main.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/unix/main.c b/unix/main.c
index 9f9f07c255..dd3fa533c2 100644
--- a/unix/main.c
+++ b/unix/main.c
@@ -130,7 +130,12 @@ STATIC int execute_from_lexer(mp_lexer_t *lex, mp_parse_input_kind_t input_kind,
// check for SystemExit
mp_obj_t exc = (mp_obj_t)nlr.ret_val;
if (mp_obj_is_subclass_fast(mp_obj_get_type(exc), &mp_type_SystemExit)) {
- exit(mp_obj_get_int(mp_obj_exception_get_value(exc)));
+ mp_obj_t exit_val = mp_obj_exception_get_value(exc);
+ mp_int_t val;
+ if (!mp_obj_get_int_maybe(exit_val, &val)) {
+ val = 0;
+ }
+ exit(val);
}
mp_obj_print_exception((mp_obj_t)nlr.ret_val);
return 1;