Skip to content

Commit 4938851

Browse files
committed
remove legacy sys.atexit() implementation
1 parent a3998d0 commit 4938851

File tree

9 files changed

+4
-67
lines changed

9 files changed

+4
-67
lines changed

ports/unix/main.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -690,13 +690,6 @@ MP_NOINLINE int main_(int argc, char **argv) {
690690
MP_STATE_THREAD(prof_trace_callback) = MP_OBJ_NULL;
691691
#endif
692692

693-
#if MICROPY_PY_SYS_ATEXIT
694-
// Beware, the sys.settrace callback should be disabled before running sys.atexit.
695-
if (mp_obj_is_callable(MP_STATE_VM(sys_exitfunc))) {
696-
mp_call_function_0(MP_STATE_VM(sys_exitfunc));
697-
}
698-
#endif
699-
700693
#if MICROPY_PY_MICROPYTHON_MEM_INFO
701694
if (mp_verbose_flag) {
702695
mp_micropython_mem_info(0, NULL);

ports/unix/mpconfigport.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@
106106
#define MICROPY_PY_BUILTINS_SLICE_ATTRS (1)
107107
#define MICROPY_PY_BUILTINS_SLICE_INDICES (1)
108108
#define MICROPY_PY_SYS_EXIT (1)
109-
#define MICROPY_PY_SYS_ATEXIT (1)
110109
#if MICROPY_PY_SYS_SETTRACE
111110
#define MICROPY_PERSISTENT_CODE_SAVE (1)
112111
#define MICROPY_COMP_CONST (0)

py/modsys.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -166,16 +166,6 @@ STATIC mp_obj_t mp_sys_getsizeof(mp_obj_t obj) {
166166
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_sys_getsizeof_obj, mp_sys_getsizeof);
167167
#endif
168168

169-
#if MICROPY_PY_SYS_ATEXIT
170-
// atexit(callback): Callback is called when sys.exit is called.
171-
STATIC mp_obj_t mp_sys_atexit(mp_obj_t obj) {
172-
mp_obj_t old = MP_STATE_VM(sys_exitfunc);
173-
MP_STATE_VM(sys_exitfunc) = obj;
174-
return old;
175-
}
176-
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_sys_atexit_obj, mp_sys_atexit);
177-
#endif
178-
179169
#if MICROPY_PY_SYS_SETTRACE
180170
// settrace(tracefunc): Set the system’s trace function.
181171
STATIC mp_obj_t mp_sys_settrace(mp_obj_t obj) {
@@ -237,14 +227,6 @@ STATIC const mp_rom_map_elem_t mp_module_sys_globals_table[] = {
237227
#if MICROPY_PY_SYS_GETSIZEOF
238228
{ MP_ROM_QSTR(MP_QSTR_getsizeof), MP_ROM_PTR(&mp_sys_getsizeof_obj) },
239229
#endif
240-
241-
/*
242-
* Extensions to CPython
243-
*/
244-
245-
#if MICROPY_PY_SYS_ATEXIT
246-
{ MP_ROM_QSTR(MP_QSTR_atexit), MP_ROM_PTR(&mp_sys_atexit_obj) },
247-
#endif
248230
};
249231

250232
STATIC MP_DEFINE_CONST_DICT(mp_module_sys_globals, mp_module_sys_globals_table);

py/mpconfig.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,11 +1311,6 @@ typedef double mp_float_t;
13111311
#define MICROPY_PY_SYS_EXIT (1)
13121312
#endif
13131313

1314-
// Whether to provide "sys.atexit" function (MicroPython extension)
1315-
#ifndef MICROPY_PY_SYS_ATEXIT
1316-
#define MICROPY_PY_SYS_ATEXIT (0)
1317-
#endif
1318-
13191314
// Whether to provide "sys.settrace" function
13201315
#ifndef MICROPY_PY_SYS_SETTRACE
13211316
#define MICROPY_PY_SYS_SETTRACE (0)

py/mpstate.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,6 @@ typedef struct _mp_state_vm_t {
157157
mp_obj_base_t *cur_exception;
158158
#endif
159159

160-
#if MICROPY_PY_SYS_ATEXIT
161-
// exposed through sys.atexit function
162-
mp_obj_t sys_exitfunc;
163-
#endif
164-
165160
// dictionary for the __main__ module
166161
mp_obj_dict_t dict_main;
167162

py/runtime.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,6 @@ void mp_init(void) {
130130
sizeof(MP_STATE_VM(fs_user_mount)) - MICROPY_FATFS_NUM_PERSISTENT);
131131
#endif
132132

133-
#if MICROPY_PY_SYS_ATEXIT
134-
MP_STATE_VM(sys_exitfunc) = mp_const_none;
135-
#endif
136-
137133
#if MICROPY_PY_SYS_SETTRACE
138134
MP_STATE_THREAD(prof_trace_callback) = MP_OBJ_NULL;
139135
MP_STATE_THREAD(prof_callback_is_executing) = false;

tests/misc/sys_atexit.py

Lines changed: 0 additions & 21 deletions
This file was deleted.

tests/misc/sys_atexit.py.exp

Lines changed: 0 additions & 2 deletions
This file was deleted.

tests/unix/extra_coverage.py.exp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ ime
4141

4242
utime utimeq
4343

44-
argv atexit byteorder exc_info
45-
exit getsizeof implementation maxsize
46-
modules path platform stderr
47-
stdin stdout version version_info
44+
argv byteorder exc_info exit
45+
getsizeof implementation maxsize modules
46+
path platform stderr stdin
47+
stdout version version_info
4848
ementation
4949
# attrtuple
5050
(start=1, stop=2, step=3)

0 commit comments

Comments
 (0)