Skip to content

Commit a686410

Browse files
pi-anldpgeorge
authored andcommitted
shared/runtime/pyexec: Set PYEXEC_FORCED_EXIT flag for SystemExit.
When `MICROPY_PYEXEC_ENABLE_EXIT_CODE_HANDLING` is enabled, `SystemExit` now sets the `PYEXEC_FORCED_EXIT` flag in addition to the exit code. This allows the REPL to properly detect and exit when SystemExit is raised, while still preserving the exit code in the lower bits. Fixes `repl_lock.py` test which expects REPL to exit on `SystemExit`. Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
1 parent 5f815b8 commit a686410

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

shared/runtime/pyexec.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ static int parse_compile_execute(const void *source, mp_parse_input_kind_t input
178178
} else {
179179
ret = PYEXEC_NORMAL_EXIT;
180180
}
181+
// Set PYEXEC_FORCED_EXIT flag so REPL knows to exit
182+
ret |= PYEXEC_FORCED_EXIT;
181183
#else
182184
ret = PYEXEC_FORCED_EXIT;
183185
#endif

0 commit comments

Comments
 (0)