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
7a4ddd24
Commit
7a4ddd24
authored
May 24, 2014
by
Damien George
Browse files
Add SystemExit exception and use it in unix/ and stmhal/ ports.
Addresses issue #598.
parent
ee3fd46f
Changes
5
Show whitespace changes
Inline
Side-by-side
py/obj.h
View file @
7a4ddd24
...
...
@@ -344,6 +344,7 @@ extern const mp_obj_type_t mp_type_RuntimeError;
extern
const
mp_obj_type_t
mp_type_StopIteration
;
extern
const
mp_obj_type_t
mp_type_SyntaxError
;
extern
const
mp_obj_type_t
mp_type_SystemError
;
extern
const
mp_obj_type_t
mp_type_SystemExit
;
extern
const
mp_obj_type_t
mp_type_TypeError
;
extern
const
mp_obj_type_t
mp_type_ValueError
;
extern
const
mp_obj_type_t
mp_type_ZeroDivisionError
;
...
...
py/objexcept.c
View file @
7a4ddd24
...
...
@@ -159,7 +159,7 @@ const mp_obj_type_t mp_type_ ## exc_name = { \
// List of all exceptions, arranged as in the table at:
// http://docs.python.org/3.3/library/exceptions.html
MP_DEFINE_EXCEPTION_BASE
(
BaseException
)
//
MP_DEFINE_EXCEPTION(SystemExit, BaseException)
MP_DEFINE_EXCEPTION
(
SystemExit
,
BaseException
)
//MP_DEFINE_EXCEPTION(KeyboardInterrupt, BaseException)
MP_DEFINE_EXCEPTION
(
GeneratorExit
,
BaseException
)
MP_DEFINE_EXCEPTION
(
Exception
,
BaseException
)
...
...
py/qstrdefs.h
View file @
7a4ddd24
...
...
@@ -102,6 +102,7 @@ Q(OverflowError)
Q
(
RuntimeError
)
Q
(
SyntaxError
)
Q
(
SystemError
)
Q
(
SystemExit
)
Q
(
TypeError
)
Q
(
UnboundLocalError
)
Q
(
ValueError
)
...
...
stmhal/main.c
View file @
7a4ddd24
...
...
@@ -556,7 +556,6 @@ STATIC NORETURN mp_obj_t mp_sys_exit(uint n_args, const mp_obj_t *args) {
if
(
n_args
>
0
)
{
rc
=
mp_obj_get_int
(
args
[
0
]);
}
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_NotImplementedError
,
"sys.exit(%d) called, is not fully implemented"
,
rc
));
nlr_raise
(
mp_obj_new_exception_arg1
(
&
mp_type_SystemExit
,
mp_obj_new_int
(
rc
)));
}
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN
(
mp_sys_exit_obj
,
0
,
1
,
mp_sys_exit
);
unix/main.c
View file @
7a4ddd24
...
...
@@ -123,6 +123,11 @@ STATIC int execute_from_lexer(mp_lexer_t *lex, mp_parse_input_kind_t input_kind,
return
0
;
}
else
{
// uncaught exception
// 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_print_exception
((
mp_obj_t
)
nlr
.
ret_val
);
return
1
;
}
...
...
@@ -383,7 +388,7 @@ STATIC mp_obj_t mp_sys_exit(uint n_args, const mp_obj_t *args) {
if
(
n_args
>
0
)
{
rc
=
mp_obj_get_int
(
args
[
0
]);
}
exi
t
(
rc
);
nlr_raise
(
mp_obj_new_exception_arg1
(
&
mp_type_SystemExit
,
mp_obj_new_in
t
(
rc
)
))
;
}
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN
(
mp_sys_exit_obj
,
0
,
1
,
mp_sys_exit
);
...
...
Write
Preview
Supports
Markdown
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