Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
8f81b5cb
Commit
8f81b5cb
authored
Aug 16, 2014
by
Damien George
Browse files
py: Put SystemExit in builtin namespace.
Also fix unix port so that SystemExit with no arg exits with value 0.
parent
b63be37b
Changes
2
Hide whitespace changes
Inline
Side-by-side
py/builtintables.c
View file @
8f81b5cb
...
...
@@ -138,6 +138,7 @@ STATIC const mp_map_elem_t mp_builtin_object_table[] = {
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_StopIteration
),
(
mp_obj_t
)
&
mp_type_StopIteration
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_SyntaxError
),
(
mp_obj_t
)
&
mp_type_SyntaxError
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_SystemError
),
(
mp_obj_t
)
&
mp_type_SystemError
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_SystemExit
),
(
mp_obj_t
)
&
mp_type_SystemExit
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_TypeError
),
(
mp_obj_t
)
&
mp_type_TypeError
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_ValueError
),
(
mp_obj_t
)
&
mp_type_ValueError
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_ZeroDivisionError
),
(
mp_obj_t
)
&
mp_type_ZeroDivisionError
},
...
...
unix/main.c
View file @
8f81b5cb
...
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment