diff options
| author | Milan Rossa | 2019-08-05 15:06:41 +0200 |
|---|---|---|
| committer | Damien George | 2019-08-15 17:30:50 +1000 |
| commit | cb3647004fbf7b069a3509a02b72420828369bd3 (patch) | |
| tree | 403306b62da8464cb3ac5d3a59404c6669f8e6f1 /py/mpstate.h | |
| parent | 2ccf030fd1ee7ddf7c015217c7fbc9996c735fd1 (diff) | |
py: Implement new sys.atexit feature.
This patch implements a new sys.atexit function which registers a function
that is later executed when the main script ends. It is configurable via
MICROPY_PY_SYS_ATEXIT, disabled by default.
This is not compliant with CPython, rather it can be used to implement a
CPython compatible "atexit" module if desired (similar to how
sys.print_exception can be used to implement functionality of the
"traceback" module).
Diffstat (limited to 'py/mpstate.h')
| -rw-r--r-- | py/mpstate.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/py/mpstate.h b/py/mpstate.h index b7eb6bdeb..1057cef04 100644 --- a/py/mpstate.h +++ b/py/mpstate.h @@ -149,6 +149,11 @@ typedef struct _mp_state_vm_t { mp_obj_base_t *cur_exception; #endif + #if MICROPY_PY_SYS_ATEXIT + // exposed through sys.atexit function + mp_obj_t sys_exitfunc; + #endif + // dictionary for the __main__ module mp_obj_dict_t dict_main; |
